# https://www.wolfram.com/mathematica/compare-mathematica/files/NumericsComparisonMathematica13.2Maple2022.pdf mapleVersion := StringTools['DeleteSpace'](StringTools['Take'](convert(kernelopts(version), string), 10)); with (LinearAlgebra); with (DiscreteTransforms); with (combinat, fibonacci); with (Statistics); with (Student[Statistics]); with (RandomTools[MersenneTwister]); with (Optimization); with (RandomTools); with (stats); with (combinat); with (ArrayTools); WARNING(currentdir(String(kernelopts('homedir'), "/Desktop"(*, "/BenchmarkData"*)))); steps := 8; repeats := 5; maxVector := 10^5; maxMatrix := 2000; maxSparseMatrix := 20000; makeData := proc (type, size) local dat, i; if type = "Vector" then dat := RandomVector[row] (size, generator = 0. .. 1.0); elif type = "Matrix" then dat := Generate (' Matrix' (float (range = -10 .. 10, method = uniform), size, size)); elif type = "VectorFloat8" then dat := RandomVector[row] (size, generator = 0. .. 1.0, datatype = float[8]); elif type = "MatrixFloat8" then dat := RandomMatrix (size, size, generator = -10.0 .. 10.0, datatype = float[8]); elif type = "UpperTriangularFloat8" then dat := UpperTriangle (1.0+makeData ("MatrixFloat8", size)); elif type = "UpperTriangularMatrix" then dat := UpperTriangle (1.0+makeData ("Matrix", size)); elif type = "SparseMatrix" then dat := Matrix (size, size, storage = sparse); for i to floor (1/10000*size^2) do dat[RandomTools[Generate] (integer (range = 1 .. size)), Generate (integer (range = 1 .. size))] := 2*GenerateFloat (); od; elif type = "MediumSparseMatrix" then dat := Matrix (size, size, storage = sparse); for i to floor (1/200*size^2) do dat[RandomTools[Generate] (integer (range = 1 .. size)), Generate (integer (range = 1 .. size))] := GenerateFloat (); od; elif type = "SparseVector" then dat := Vector (size, 1.0, storage = sparse); for i to floor (1/10000*size) do dat[RandomTools[Generate] (integer (range = 1 .. size))] := GenerateFloat (); od; elif type = "IntegerMatrix" then dat := Generate (' Matrix' (integer (range = -10 .. 10), size, size)); elif type = "IntegerVector" then dat := Generate (' Vector' (integer (range = -10 .. 10), size)); elif type = "IntegerMatrix8" then dat := Generate (' Matrix' (integer (range = -10 .. 10), size, size, datatype = integer[8])); elif type = "IntegerVector8" then dat := Generate (' Vector' (integer (range = -10 .. 10), size, datatype = integer[8])); elif type = "BigNumberMatrix" then dat := RandomMatrix (size, size, generator = (proc (x) 20*GenerateFloat (digits = 50) - 10; end proc)); elif type = "BigNumberVector" then dat := RandomVector[row] (size, generator = (proc (x) 20*GenerateFloat (digits = 50) - 10; end proc)); elif type = "BigNumberMatrix1000" then dat := RandomMatrix (size, size, generator = (proc (x) 20*GenerateFloat (digits = 1000) - 10; end proc)); elif type = "BigNumberVector1000" then dat := RandomVector[row] (size, generator = (proc (x) 20*GenerateFloat (digits = 1000) - 10; end proc)); elif type = "ComplexVector" then dat := makeData ("Vector", size) + makeData ("Vector", size)*I; elif type = "ComplexMatrix" then dat := makeData ("Matrix", size) + makeData ("Matrix", size)*I; elif type = "ComplexVector8" then dat := makeData ("VectorFloat8", size) + makeData ("VectorFloat8", size)*I; elif type = "ComplexMatrix8" then dat := makeData ("MatrixFloat8", size) + makeData ("MatrixFloat8", size)*I; else print (type); fi; dat; end proc; timedDataOperation := proc (expr, size, type) local totaltime, data, i; totaltime := 0; for i to repeats do data := makeData (type, round (size)); totaltime := totaltime + time[real] (expr (data)); od; totaltime/repeats; end proc; timedReport := proc (filename, expr, hi, type) local s; ExportMatrix (cat (mapleVersion, filename, ".txt"), convert ([seq ([floor (s), timedDataOperation ('expr', floor (s), type)], s = hi/steps .. hi, hi/steps)], Matrix)); end proc; numericfntest := proc (fn, n, type) local data; data := makeData (type, round (n)); time[real] (map (fn, data)); end proc; numerictest := proc (file, fns, n, type) local i; ExportMatrix (cat (mapleVersion, file, ".txt"), Matrix ([seq (numericfntest (i, n, type), i in fns)])); end proc; numerictestinplace := proc (file, fns, n, type) local i; ExportMatrix (cat (mapleVersion, file, ".txt"), Matrix ([seq (numericfntestinplace (i, n, type), i in fns)])); end proc; numerictestelementwise := proc (file, fns, n, type) local i; ExportMatrix (cat (mapleVersion, file, ".txt"), Matrix ([seq (elementwisefntest (i, n, type), i in fns)])); end proc; numericfntestinplace := proc (fn, n, type) local data; data := makeData (type, round (n)); time[real] (Map (fn, data)); end proc; elementwisefntest := proc (fn, n, type) local data; data := makeData (type, round (n)); time[real] (fn (data)); end proc; highPrecisionTest := proc (file, fns, n) local i; ExportMatrix (cat (mapleVersion, file, ".txt"), Matrix ([seq (time[real] (evalf (i, n)), i in fns)])); end proc; (*RandomInteger := proc (x, y) RandomTools[Generate] (integer (range = 1 .. 100)); end proc;*) fnList := [sqrt, sin, cos, tan, arcsin, arccos, arctan, sec, csc, cot, exp, sinh, cosh, tanh, log, log10, erf, GAMMA, proc (x) option inline; BesselJ (0, x); end, proc (x) option inline; BesselK (1, x); end, proc (x) option inline; BesselY (3, x); end, arcsinh, proc (x) option inline; arccosh (x + 1); end, arctanh, Zeta, proc (x) options inline; x*sin (log (x) + 2*sqrt (x) + 3) + sqrt (x) + log (x); end, proc (x) option inline; sin (cos (x)); end, proc (x) option inline; log (sinh (x)); end, proc (x) erf (sin (x)); end, proc (x) option inline; exp (x^2); end, Psi, proc (x) option inline; x + 1; end, proc (x) option inline; 1/x; end, proc (x) option inline; x^2; end, proc (x) option inline; frem (x, 0.5); end]; elementwisefnList := [`~`[sqrt], `~`[sin], `~`[cos], `~`[tan], `~`[arcsin], `~`[arccos], `~`[arctan], `~`[sec], `~`[csc], `~`[cot], `~`[exp], `~`[sinh], `~`[cosh], `~`[tanh], `~`[log], `~`[log10], `~`[erf], `~`[GAMMA], `~`[proc (x) option inline; BesselJ (0, x); end], `~`[proc (x) option inline; BesselK (1, x); end], `~`[proc (x) option inline; BesselY (3, x); end], `~`[arcsinh], `~`[proc (x) option inline; arccosh (x + 1); end], `~`[arctanh], `~`[Zeta], `~`[proc (x) options inline; x*sin (log (x) + 2*sqrt (x) + 3) + sqrt (x) + log (x); end], `~`[proc (x) option inline; sin (cos (x)); end], `~`[proc (x) option inline; log (sinh (x)); end], `~`[proc (x) option inline; erf (sin (x)); end], `~`[proc (x) option inline; exp (x^2); end], `~`[Psi], `~`[proc (x) option inline; x + 1; end], `~`[proc (x) option inline; 1/x; end], `~`[proc (x) option inline; x^2; end], `~`[proc (x) option inline; frem (x, 0.5); end]]; timedReport ("DotSparse", ' proc (x) x . x; end proc', maxSparseMatrix, "SparseMatrix"); timedReport ("FlattenSparse", ' proc (m) convert (m, Vector[row]); end proc', 10*maxMatrix, "SparseMatrix"); timedReport ("MatrixPowerSparse", ' proc (x) x^5; end proc', 4*maxMatrix, "SparseMatrix"); timedReport ("ElementPowerSparse", ' proc (m) map (proc (x) x^5; end proc, m); end proc', maxSparseMatrix, "SparseMatrix"); timedReport ("MeanSparse", ' Statistics :- Mean', 100*maxVector, "SparseVector"); timedReport ("LinearProgrammingSparse", ' proc (x) LPSolve (abs (Row (x, 1)), [-abs (x), -abs (Row (x, 2))], [0, infinity], iterationlimit = 1000); end proc', 1/10*maxSparseMatrix, "MediumSparseMatrix"); timedReport ("LinearSolveSparse", ' proc (x) LinearSolve (x, Column (x, 1), methodoptions = [maxiter = 10000]); end proc', maxSparseMatrix, "SparseMatrix"); timedReport ("TransposeSparse", ' Transpose', 2*maxSparseMatrix, "SparseMatrix"); timedReport ("FourierReal", ' FourierTransform', maxVector, "Vector"); timedReport ("SortReal", ' sort', maxVector, "Vector"); timedReport ("MeanReal", ' Statistics :- Mean', 2*maxVector, "Vector"); timedReport ("DotReal", ' proc (x) x . x; end proc', maxMatrix, "Matrix"); timedReport ("InverseReal", ' MatrixInverse', maxMatrix, "Matrix"); timedReport ("LinearSolveReal", ' proc (x) LinearSolve (x, Column (x, 1)); end proc', maxMatrix, "Matrix"); timedReport ("CholeskyReal", ' proc (S) LUDecomposition ((Transpose (S)) . S, method = ' Cholesky'); end proc', maxMatrix, "Matrix"); timedReport ("MatrixPowerReal", ' proc (x) x^5; end proc', maxMatrix, "Matrix"); timedReport ("DetReal", ' Determinant', maxMatrix, "Matrix"); timedReport ("TransposeReal", ' Transpose', maxMatrix, "Matrix"); timedReport ("FlattenReal", ' proc (m) convert (m, Vector[row]); end proc', maxMatrix, "Matrix"); timedReport ("EigenvaluesReal", ' Eigenvalues', 1/2*maxMatrix, "Matrix"); timedReport ("EigenvectorsReal", ' Eigenvectors', 1/2*maxMatrix, "Matrix"); timedReport ("LinearProgrammingReal", ' proc (x) LPSolve (abs (Row (x, 1)), [-abs (x), -abs (Row (x, 2))], [0, infinity]); end proc', maxMatrix/4, "Matrix"); timedReport ("ElementPowerReal", ' proc (m) map (proc (x) x^5; end proc, m); end proc', 1/2*maxMatrix, "Matrix"); timedReport ("FitReal", ' proc (m) Fit (b*x + a, m, m, x); end proc', maxVector, "Vector"); timedReport ("MatrixExpReal", ' MatrixExponential', maxMatrix/5, "Matrix"); timedReport ("CovarianceReal", ' CovarianceMatrix', maxMatrix, "Matrix"); timedReport ("MatrixRankReal", ' LinearAlgebra :- Rank', 3*maxMatrix, "Matrix"); timedReport ("LUDecompositionReal", ' LUDecomposition', maxMatrix, "Matrix"); timedReport ("LeastSquaresReal", ' proc (x) LeastSquares (x, Column (x, 1)); end proc', maxMatrix, "Matrix"); timedReport ("FourierFloat8", ' FourierTransform', maxVector, "VectorFloat8"); timedReport ("SortFloat8", ' sort', maxVector, "VectorFloat8"); timedReport ("MeanFloat8", ' Statistics :- Mean', 10*maxVector, "VectorFloat8"); timedReport ("DotFloat8", ' proc (x) x . x; end proc', maxMatrix, "MatrixFloat8"); timedReport ("InverseFloat8", ' MatrixInverse', maxMatrix, "MatrixFloat8"); timedReport ("LinearSolveFloat8", ' proc (x) LinearSolve (x, Column (x, 1)); end proc', maxMatrix, "MatrixFloat8"); timedReport ("CholeskyFloat8", ' proc (S) LUDecomposition ((Transpose (S)) . S, method = ' Cholesky'); end proc', maxMatrix, "MatrixFloat8"); timedReport ("MatrixPowerFloat8", ' proc (x) x^5; end proc', maxMatrix, "MatrixFloat8"); timedReport ("DetFloat8", ' Determinant', maxMatrix, "MatrixFloat8"); timedReport ("TransposeFloat8", ' Transpose', maxMatrix, "MatrixFloat8"); timedReport ("FlattenFloat8", ' proc (m) convert (m, Vector[row]); end proc', maxMatrix, "MatrixFloat8"); timedReport ("EigenvaluesFloat8", ' Eigenvalues', 1/2*maxMatrix, "MatrixFloat8"); timedReport ("EigenvectorsFloat8", ' Eigenvectors', 1/2*maxMatrix, "MatrixFloat8"); timedReport ("LinearProgrammingFloat8", ' proc (x) LPSolve (abs (Row (x, 1)), [-abs (x), -abs (Row (x, 2))], [0, infinity]); end proc', 1/4*maxMatrix, "MatrixFloat8"); timedReport ("ElementPowerFloat8", ' proc (m) map (proc (x) x^5; end proc, m); end proc', 1/2*maxMatrix, "MatrixFloat8"); timedReport ("FitFloat8", ' proc (m) Fit (b*x + a, m, m, x); end proc', maxVector, "VectorFloat8"); timedReport ("MatrixExpFloat8", ' MatrixExponential', maxMatrix/5, "MatrixFloat8"); timedReport ("CovarianceFloat8", ' CovarianceMatrix', maxMatrix, "MatrixFloat8"); timedReport ("MatrixRankFloat8", ' LinearAlgebra :- Rank', 3*maxMatrix, "MatrixFloat8"); timedReport ("LUDecompositionFloat8", ' LUDecomposition', maxMatrix, "MatrixFloat8"); timedReport ("LeastSquaresFloat8", ' proc (x) LeastSquares (x, Column (x, 1)); end proc', maxMatrix, "MatrixFloat8"); timedReport ("LinearProgrammingReal", ' proc (x) LPSolve (abs (Row (x, 1)), [-abs (x), -abs (Row (x, 2))], [0, infinity]); end proc', maxMatrix, "Matrix"); timedReport ("LinearProgrammingFloat8", ' proc (x) LPSolve (abs (Row (x, 1)), [-abs (x), -abs (Row (x, 2))], [0, infinity]); end proc', maxMatrix, "MatrixFloat8"); timedReport ("FourierComplex", ' FourierTransform', maxVector, "ComplexVector"); timedReport ("SortComplex", ' sort', maxVector, "ComplexVector"); timedReport ("DetUpperTriangularFloat8", ' Determinant', maxMatrix, "UpperTriangularFloat8"); timedReport ("EigenvaluesUpperTriangularFloat8", ' Eigenvalues', maxMatrix, "UpperTriangularFloat8"); timedReport ("EigenvectorsUpperTriangularFloat8", ' Eigenvectors', maxMatrix, "UpperTriangularFloat8"); timedReport ("InverseUpperTriangularFloat8", ' MatrixInverse', maxMatrix, "UpperTriangularFloat8"); timedReport ("MatrixPowerUpperTriangularFloat8", ' proc (x) x^5; end proc', maxMatrix, "UpperTriangularFloat8"); timedReport ("EigenvaluesUpperTriangularReal", ' Eigenvalues', maxMatrix, "UpperTriangularMatrix"); timedReport ("EigenvectorsUpperTriangularReal", ' Eigenvectors', maxMatrix, "UpperTriangularMatrix"); timedReport ("InverseUpperTriangularReal", ' MatrixInverse', maxMatrix, "UpperTriangularMatrix"); timedReport ("MatrixPowerUpperTriangularReal", ' proc (x) x^5; end proc', maxMatrix, "UpperTriangularMatrix"); timedReport("LUDecompositionTriangularFloat8", 'LUDecomposition', maxMatrix, "UpperTriangularFloat8"); timedReport("LUDecompositionTriangularReal", 'LUDecomposition', maxMatrix, "UpperTriangularMatrix"); timedReport("QRDecompositionUpperTriangularFloat8", 'QRDecomposition', maxMatrix, "UpperTriangularFloat8"); timedReport("QRDecompositionUpperTriangularReal", 'QRDecomposition', maxMatrix, "UpperTriangularMatrix"); timedReport ("DotComplex", ' proc (x) x . x; end proc', maxMatrix, "ComplexMatrix"); timedReport ("InverseComplex", ' MatrixInverse', maxMatrix, "ComplexMatrix"); timedReport ("LinearSolveComplex", ' proc (x) LinearSolve (x, Column (x, 1)); end proc', maxMatrix, "ComplexMatrix"); timedReport ("CholeskyComplex", ' proc (S) LUDecomposition ((map (conjugate, Transpose (S))) . S, method = ' Cholesky'); end proc', maxMatrix, "ComplexMatrix"); timedReport ("MatrixPowerComplex", ' proc (x) x^5; end proc', 1/2*maxMatrix, "ComplexMatrix"); timedReport ("MeanComplex", ' (Student[Statistics]) :- Mean', 1/3*maxVector, "ComplexVector"); timedReport ("DetComplex", ' Determinant', maxMatrix, "ComplexMatrix"); timedReport ("EigenvaluesComplex", ' Eigenvalues', 1/2*maxMatrix, "ComplexMatrix"); timedReport ("EigenvectorsComplex", ' Eigenvectors', maxMatrix, "ComplexMatrix"); timedReport ("TransposeComplex", ' Transpose', maxMatrix, "ComplexMatrix"); timedReport ("FlattenComplex", ' proc (m) convert (m, Vector[row]); end proc', maxMatrix, "ComplexMatrix"); timedReport ("ElementPowerComplex", ' proc (m) map (proc (x) x^5; end proc, m); end proc', 1/4*maxMatrix, "ComplexMatrix"); timedReport ("MatrixExpComplex", ' MatrixExponential', 1400, "ComplexMatrix"); timedReport ("MatrixRankComplex", ' LinearAlgebra :- Rank', 3*maxMatrix, "ComplexMatrix"); timedReport ("LUDecompositionComplex", ' LUDecomposition', maxMatrix, "ComplexMatrix"); timedReport ("LeastSquaresComplex", ' proc (x) LeastSquares (x, Column (x, 1)); end proc', maxMatrix, "ComplexMatrix"); timedReport ("FourierComplex8", ' FourierTransform', maxVector, "ComplexVector8"); timedReport ("SortComplex8", ' sort', maxVector, "ComplexVector"); timedReport ("MeanComplex8", ' (Student[Statistics]) :- Mean', 1/3*maxVector, "ComplexVector8"); timedReport ("DotComplex8", ' proc (x) x . x; end proc', maxMatrix, "ComplexMatrix8"); timedReport ("InverseComplex8", ' MatrixInverse', maxMatrix, "ComplexMatrix8"); timedReport ("LinearSolveComplex8", ' proc (x) LinearSolve (x, Column (x, 1)); end proc', maxMatrix, "ComplexMatrix8"); timedReport ("CholeskyComplex8", ' proc (S) LUDecomposition ((map (conjugate, Transpose (S))) . S, method = ' Cholesky'); end proc', maxMatrix, "ComplexMatrix8"); timedReport ("MatrixPowerComplex8", ' proc (x) x^5; end proc', 1/2*maxMatrix, "ComplexMatrix8"); timedReport ("DetComplex8", ' Determinant', maxMatrix, "ComplexMatrix8"); timedReport ("EigenvaluesComplex8", ' Eigenvalues', 1/2*maxMatrix, "ComplexMatrix8"); timedReport ("EigenvectorsComplex8", ' Eigenvectors', maxMatrix, "ComplexMatrix8"); timedReport ("TransposeComplex8", ' Transpose', maxMatrix, "ComplexMatrix8"); timedReport ("FlattenComplex8", ' proc (m) convert (m, Vector[row]); end proc', maxMatrix, "ComplexMatrix8"); timedReport ("ElementPowerComplex8", ' proc (m) map (proc (x) x^5; end proc, m); end proc', 1/4*maxMatrix, "ComplexMatrix8"); timedReport ("MatrixExpComplex8", ' MatrixExponential', maxMatrix/2, "ComplexMatrix8"); timedReport ("MatrixRankComplex8", ' LinearAlgebra :- Rank', 3*maxMatrix, "ComplexMatrix8"); timedReport ("LUDecompositionComplex8", ' LUDecomposition', maxMatrix, "ComplexMatrix8"); timedReport ("LeastSquaresComplex8", ' proc (x) LeastSquares (x, Column (x, 1)); end proc', maxMatrix, "ComplexMatrix8"); timedReport ("DotInteger", ' proc (x) x . x; end proc', maxMatrix, "IntegerMatrix"); timedReport ("InverseInteger", ' MatrixInverse', 1/20*maxMatrix, "IntegerMatrix"); timedReport ("LinearSolveInteger", ' proc (x) LinearSolve (x, Column (x, 1)); end proc', 1/4*maxMatrix, "IntegerMatrix"); timedReport ("MatrixPowerInteger", ' proc (x) x^5; end proc', 500, "IntegerMatrix"); timedReport ("DetInteger", ' Determinant', 700, "IntegerMatrix"); timedReport ("TransposeInteger", ' Transpose', maxMatrix, "IntegerMatrix"); timedReport ("FlattenInteger", ' proc (m) convert (m, Vector[row]); end proc', maxMatrix, "IntegerMatrix"); timedReport ("MeanInteger", ' (Student[Statistics]) :- Mean', maxVector, "IntegerVector"); timedReport ("SortInteger", ' sort', maxVector, "IntegerVector"); timedReport ("EigenvaluesInteger", ' Eigenvalues', 1/30*maxMatrix, "IntegerMatrix"); timedReport ("ElementPowerInteger", ' proc (m) map (proc (x) x^5; end proc, m); end proc', maxMatrix, "IntegerMatrix"); timedReport ("DotInteger8", ' proc (x) x . x; end proc', maxMatrix, "IntegerMatrix8"); timedReport ("LinearSolveInteger8", ' proc (x) LinearSolve (x, Column (x, 1)); end proc', 1/4*maxMatrix, "IntegerMatrix8"); timedReport ("MatrixPowerInteger8", ' proc (x) x^5; end proc', 1/4*maxMatrix, "IntegerMatrix8"); timedReport ("DetInteger8", ' Determinant', 700, "IntegerMatrix8"); timedReport ("TransposeInteger8", ' Transpose', maxMatrix, "IntegerMatrix8"); timedReport ("FlattenInteger8", ' proc (m) convert (m, Vector[row]); end proc', maxMatrix, "IntegerMatrix8"); timedReport ("MeanInteger8", ' (Student[Statistics]) :- Mean', maxVector, "IntegerVector8"); timedReport ("SortInteger8", ' sort', maxVector, "IntegerVector8"); timedReport ("EigenvaluesInteger8", ' Eigenvalues', 1/30*maxMatrix, "IntegerMatrix8"); timedReport ("ElementPowerInteger8", ' proc (m) map (proc (x) x^5; end proc, m); end proc', maxMatrix, "IntegerMatrix8"); steps := 3; timedReport ("MatrixExpInteger8", ' MatrixExponential', 3, "IntegerMatrix8"); timedReport ("MatrixExpInteger", ' MatrixExponential', 3, "IntegerMatrix"); steps := 10; timedReport ("SortCustomFloat8", ' proc (data) sort (data, proc (x, y) abs (y) < abs (x); end proc); end proc', maxVector/25, "VectorFloat8"); timedReport ("SortCustomReal", ' proc (data) sort (data, proc (x, y) abs (y) < abs (x); end proc); end proc', maxVector/25, "Vector"); timedReport ("SortCustomComplex", ' proc (data) sort (data, proc (x, y) abs (y) < abs (x); end proc); end proc', maxVector/25, "ComplexVector"); timedReport ("SortCustomComplex8", ' proc (data) sort (data, proc (x, y) abs (y) < abs (x); end proc); end proc', maxVector/25, "ComplexVector8"); timedReport ("SortCustomInteger", ' proc (data) sort (data, proc (x, y) abs (y) < abs (x); end proc); end proc', maxVector/25, "IntegerVector"); timedReport ("SortCustomInteger8", ' proc (data) sort (data, proc (x, y) abs (y) < abs (x); end proc); end proc', 100000, "IntegerVector8"); timedReport ("MatrixRankInteger", ' LinearAlgebra :- Rank', maxMatrix/5, "IntegerMatrix"); timedReport ("MatrixRankInteger8", ' LinearAlgebra :- Rank', maxMatrix/5, "IntegerMatrix8"); ExportMatrix(cat (mapleVersion, "RandomNumbers.txt"), Matrix ([[time[real] (makeData ("Matrix", 2000)), time[real] (makeData ("MatrixFloat8", 2000)), time[real] (makeData ("IntegerMatrix", 2000)), time[real] (makeData ("IntegerMatrix8", 2000)), time[real] (makeData ("BigNumberMatrix", 2000)), time[real] (makeData ("BigNumberMatrix1000", 2000)), time[real] (Sample (RandomVariable (Normal (0, 1)), 10^7)), time[real] (Sample (RandomVariable (Poisson (4)), 10^7)), time[real] (Sample (RandomVariable (BinomialDistribution (10, 0.2)), 10^7))]])); timedReport ("SingularValuesReal", ' SingularValues', maxMatrix, "Matrix"); timedReport ("SingularValuesFloat8", ' SingularValues', maxMatrix, "MatrixFloat8"); timedReport ("SingularValuesComplex", ' SingularValues', maxMatrix, "ComplexMatrix"); timedReport ("SingularValuesComplex8", ' SingularValues', maxMatrix, "ComplexMatrix8"); timedReport ("SingularValuesInteger", ' SingularValues', maxMatrix/50, "IntegerMatrix"); timedReport ("SingularValuesInteger8", ' SingularValues', maxMatrix/50, "IntegerMatrix8"); timedReport ("QRDecompositionReal", ' SingularValues', maxMatrix, "Matrix"); timedReport ("QRDecompositionFloat8", ' SingularValues', maxMatrix, "MatrixFloat8"); timedReport ("QRDecompositionComplex", ' QRDecomposition', maxMatrix, "ComplexMatrix"); timedReport ("QRDecompositionComplex8", ' QRDecomposition', maxMatrix, "ComplexMatrix8"); timedReport ("QRDecompositionInteger", ' QRDecomposition', maxMatrix/50, "IntegerMatrix"); timedReport ("QRDecompositionInteger8", ' QRDecomposition', maxMatrix/50, "IntegerMatrix8"); numerictest ("ElementaryFunctionsReal", fnList, maxVector, "Vector"); numerictest ("ElementaryFunctionsFloat8", fnList, maxVector, "VectorFloat8"); numerictest ("ElementaryFunctionsComplex", fnList, maxVector, "ComplexVector"); numerictest ("ElementaryFunctionsComplex8", fnList, maxVector, "ComplexVector8"); numerictestinplace ("ElementaryFunctionsInPlaceFloat8", fnList, maxVector, "VectorFloat8"); numerictestinplace ("ElementaryFunctionsInPlaceComplex", fnList, maxVector, "ComplexVector"); numerictestinplace ("ElementaryFunctionsInPlaceComplex8", fnList, maxVector, "ComplexVector8"); numerictestinplace ("ElementaryFunctionsInPlaceReal", fnList, maxVector, "Vector"); numerictestelementwise ("ElementaryFunctionsElementwiseFloat8", elementwisefnList, maxVector, "VectorFloat8"); numerictestelementwise ("ElementaryFunctionsElementwiseComplex", elementwisefnList, maxVector, "ComplexVector"); numerictestelementwise ("ElementaryFunctionsElementwiseComplex8", elementwisefnList, maxVector, "ComplexVector8"); numerictestelementwise ("ElementaryFunctionsElementwiseReal", elementwisefnList, maxVector, "Vector"); numerictestinplace ("ElementaryFunctionsInPlaceSparse", fnList, 10*maxVector, "SparseVector"); numerictest ("ElementaryFunctionsSparse", fnList, 10*maxVector, "SparseVector"); numerictestelementwise ("ElementaryFunctionsElementwiseSparse", elementwisefnList, 10*maxVector, "SparseVector"); highPrecisionTest ("ManyDigits", [' Pi', ' sqrt (2)', ' sin (1) + 1/(1 + sin (1))', ' exp (1)', ' log (5)', ' tan (1 + I)'], 1000000); highPrecisionTest ("FewerDigits", [' BesselK (2, 3)', ' GAMMA (11/3)', ' erf (10)'], 5000); Digits := 50; timedReport ("DotExtended", ' proc (x) x . x; end proc', 1/25*maxMatrix, "BigNumberMatrix"); timedReport ("InverseExtended", ' MatrixInverse', 1/25*maxMatrix, "BigNumberMatrix"); timedReport ("EigenvaluesExtended", ' Eigenvalues', 60, "BigNumberMatrix"); timedReport ("LinearSolveExtended", ' proc (x) LinearSolve (x, Column (x, 1)); end proc', 1/25*maxMatrix, "BigNumberMatrix"); timedReport ("CholeskyExtended", ' proc (S) LUDecomposition ((Transpose (S)) . S, method = ' Cholesky'); end proc', 1/20*maxMatrix, "BigNumberMatrix"); timedReport ("MatrixPowerExtended", ' proc (x) x^5; end proc', 1/25*maxMatrix, "BigNumberMatrix"); timedReport ("DetExtended", ' Determinant', 1/10*maxMatrix, "BigNumberMatrix"); timedReport ("TransposeExtended", ' Transpose', maxMatrix, "BigNumberMatrix"); timedReport ("FlattenExtended", ' proc (m) convert (m, Vector[row]); end proc', maxMatrix, "BigNumberMatrix"); timedReport ("SortExtended", ' sort', 2*maxVector, "BigNumberVector"); timedReport ("MeanExtended", ' (Student[Statistics]) :- Mean', 1/10*maxVector, "BigNumberVector"); timedReport ("EigenvectorsExtended", ' Eigenvectors', 1/25*maxMatrix, "BigNumberMatrix"); timedReport ("ElementPowerExtended", ' proc (m) map (proc (x) x^5; end proc, m); end proc', 1/2*maxMatrix, "BigNumberMatrix"); timedReport ("MatrixExpExtended", ' MatrixExponential', 60, "BigNumberMatrix"); timedReport ("MatrixRankExtended", ' LinearAlgebra :- Rank', maxMatrix/10, "BigNumberMatrix"); timedReport ("SortCustomExtended", ' proc (data) sort (data, proc (x, y) abs (y) < abs (x); end proc); end proc', 2*maxVector, "BigNumberVector"); numerictest ("ElementaryFunctionsExtended", fnList, 1/10*maxVector, "BigNumberVector"); numerictestelementwise ("ElementaryFunctionsElementwiseExtended", elementwisefnList, 1/10*maxVector, "BigNumberVector"); numerictestinplace ("ElementaryFunctionsInPlaceExtended", fnList, 1/10*maxVector, "BigNumberVector"); timedReport ("SingularValuesExtended", ' SingularValues', maxMatrix/10, "BigNumberMatrix"); timedReport ("QRDecompositionExtended", ' QRDecomposition', maxMatrix/10, "BigNumberMatrix"); timedReport ("LUDecompositionExtended", ' LUDecomposition', maxMatrix/10, "BigNumberMatrix"); timedReport ("LeastSquaresExtended", ' proc (x) LeastSquares (x, Column (x, 1)); end proc', 1/25*maxMatrix, "BigNumberMatrix"); Digits := 1000; timedReport ("DotExtended1000", ' proc (x) x . x; end proc', 1/25*maxMatrix, "BigNumberMatrix1000"); timedReport ("InverseExtended1000", ' MatrixInverse', 1/25*maxMatrix, "BigNumberMatrix1000"); timedReport ("EigenvaluesExtended1000", ' Eigenvalues', 60, "BigNumberMatrix1000"); timedReport ("LinearSolveExtended1000", ' proc (x) LinearSolve (x, Column (x, 1)); end proc', 1/25*maxMatrix, "BigNumberMatrix1000"); timedReport ("CholeskyExtended1000", ' proc (S) LUDecomposition ((Transpose (S)) . S, method = ' Cholesky'); end proc', 1/20*maxMatrix, "BigNumberMatrix1000"); timedReport ("MatrixPowerExtended1000", ' proc (x) x^5; end proc', 1/25*maxMatrix, "BigNumberMatrix1000"); timedReport ("DetExtended1000", ' Determinant', 1/10*maxMatrix, "BigNumberMatrix1000"); timedReport ("TransposeExtended1000", ' Transpose', maxMatrix, "BigNumberMatrix1000"); timedReport ("FlattenExtended1000", ' proc (m) convert (m, Vector[row]); end proc', maxMatrix, "BigNumberMatrix1000"); timedReport ("SortExtended1000", ' sort', maxVector, "BigNumberVector1000"); timedReport ("MeanExtended1000", ' (Student[Statistics]) :- Mean', 1/10*maxVector, "BigNumberVector1000"); timedReport ("EigenvectorsExtended1000", ' Eigenvectors', 1/25*maxMatrix, "BigNumberMatrix1000"); timedReport ("SingularValuesExtended1000", ' SingularValues', maxMatrix/10, "BigNumberMatrix1000"); timedReport ("QRDecompositionExtended1000", ' QRDecomposition', maxMatrix/10, "BigNumberMatrix1000"); timedReport ("ElementPowerExtended1000", ' proc (m) map (proc (x) x^5; end proc, m); end proc', 1/2*maxMatrix, "BigNumberMatrix1000"); timedReport ("MatrixExpExtended1000", ' MatrixExponential', 60, "BigNumberMatrix1000"); timedReport ("SortCustomExtended1000", ' proc (data) sort (data, proc (x, y) abs (y) < abs (x); end proc); end proc', maxVector, "BigNumberVector1000"); timedReport ("MatrixRankExtended1000", ' LinearAlgebra :- Rank', maxMatrix/20, "BigNumberMatrix"); timedReport ("LUDecompositionExtended1000", ' LUDecomposition', maxMatrix/10, "BigNumberMatrix1000"); timedReport ("LeastSquaresExtended1000", ' proc (x) LeastSquares (x, Column (x, 1)); end proc', 1/25*maxMatrix, "BigNumberMatrix1000");