Academic Scheme Language Programming Assignment -- 2
Budget: $30 – $250 USD
The algorithm to do is :
the algorithm : https://en.wikipedia.org/wiki/Matrix_exponential
---
5. An algorithm for calculating the Matrix exponential.
Input: A matrix M of size n X n , epsilon (accuracy).
Output: e^M .
Languages for use:
- First language - Scheme
the inputs must be fast in 1000X1000 matrix input file
---
- In Scheme, it is permitted to use libraries only from `flomat` and only for code demonstration and categorization purposes.
In Scheme, it is not allowed to use functions that use objects, particularly not in functions that receive the values of those objects as arguments.
-in scheme you can't use set! ,!,set
-the code need to work in less than 3.5 min
- In projects, do not copy code from already implemented libraries, including those that implement algorithms.
—
You need to implement it in taylor series and lagrange reminder.
You can check you answer in (you can’t use it to implement the code)::
from scipy.linalg import expm
expM1 = expm(copyMatrix)
In scheme you have this to help you ::
#lang racket
(define path "C:/Users/yourname/Desktop/Data/data_struct(1000x1000).txt")
(define delim #rx"([ ]*(,)[ ]*)|([ ]+)")
(define (next-line-it file)
(let ((line (read-line file 'any)))
(if (eof-object? line)
(list)
(cons line (next-line-it file)))))
;Function to read a matrix from text file
(define read_data (λ(file delim)
(define file (open-input-file path))
(define lines (call-with-input-file path next-line-it))
(define numbers (map (λ(x) (string-split x delim)) lines))
(define mat (map (λ(x)(map string->number x)) numbers))
(close-input-port file)
mat))
;Function to generate a random number in interval [a, b]
(define random-real (λ(a b)
(define x (random))
(define y (random))
(define q (/ (min x y) (max x y)))
(+ a (* (- b a) q))))
(define t_start (current-inexact-milliseconds)) ;Get current time
(define m (read_data path delim))
(define t_end (current-inexact-milliseconds))
(display (- t_end t_start))
(display "\n")
(display (random-real 3 5))
;(define lst (call-with-input-file path next-line-it))
the algorithm : https://en.wikipedia.org/wiki/Matrix_exponential
---
5. An algorithm for calculating the Matrix exponential.
Input: A matrix M of size n X n , epsilon (accuracy).
Output: e^M .
Languages for use:
- First language - Scheme
the inputs must be fast in 1000X1000 matrix input file
---
- In Scheme, it is permitted to use libraries only from `flomat` and only for code demonstration and categorization purposes.
In Scheme, it is not allowed to use functions that use objects, particularly not in functions that receive the values of those objects as arguments.
-in scheme you can't use set! ,!,set
-the code need to work in less than 3.5 min
- In projects, do not copy code from already implemented libraries, including those that implement algorithms.
—
You need to implement it in taylor series and lagrange reminder.
You can check you answer in (you can’t use it to implement the code)::
from scipy.linalg import expm
expM1 = expm(copyMatrix)
In scheme you have this to help you ::
#lang racket
(define path "C:/Users/yourname/Desktop/Data/data_struct(1000x1000).txt")
(define delim #rx"([ ]*(,)[ ]*)|([ ]+)")
(define (next-line-it file)
(let ((line (read-line file 'any)))
(if (eof-object? line)
(list)
(cons line (next-line-it file)))))
;Function to read a matrix from text file
(define read_data (λ(file delim)
(define file (open-input-file path))
(define lines (call-with-input-file path next-line-it))
(define numbers (map (λ(x) (string-split x delim)) lines))
(define mat (map (λ(x)(map string->number x)) numbers))
(close-input-port file)
mat))
;Function to generate a random number in interval [a, b]
(define random-real (λ(a b)
(define x (random))
(define y (random))
(define q (/ (min x y) (max x y)))
(+ a (* (- b a) q))))
(define t_start (current-inexact-milliseconds)) ;Get current time
(define m (read_data path delim))
(define t_end (current-inexact-milliseconds))
(display (- t_end t_start))
(display "\n")
(display (random-real 3 5))
;(define lst (call-with-input-file path next-line-it))