(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 29298, 1010]*) (*NotebookOutlinePosition[ 59218, 2106]*) (* CellTagsIndexPosition[ 59174, 2102]*) (*WindowFrame->Normal*) Notebook[{ Cell["The Gauss application example", "Title"], Cell["\<\ The Gauss application example uses a text-book Gauss-elimination algorithm to \ solve a linear equation system. Two versions of the Gauss elimination \ algorithm are presented:\ \>", "Text"], Cell["\<\ GaussSolveMatlab. The algorithm is largely coded using the Matlab-like array \ section operations.\ \>", "Itemize"], Cell["\<\ GaussSolveForLoops. The algorithm is coded using traditional for-loops.\ \>", "Itemize"], Cell["\<\ Both versions of the algorithm are compiled to C++ code. The performance is \ measured, both including and without MathLink overhead.\ \>", "Text"], Cell[CellGroupData[{ Cell["Initialization", "Section"], Cell[CellGroupData[{ Cell["Load the MathCode package", "Subsection"], Cell["\<\ First put a Needs statement, to make sure that the MathCode application is \ loaded:\ \>", "Text"], Cell[BoxData[ \(Needs["\"]\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Check current directory", "Subsection"], Cell["\<\ Check the current directory, since a number of files will be placed \ there during the code generation process.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Directory[]\)], "Input"], Cell[BoxData[ \("/home/x97ponli/omath/MathCode/Demos/Gauss"\)], "Output"] }, Open ]], Cell["\<\ You might want to set the directory to some place where all \ generated files are put, e.g. the one below, or some other directory.\ \>", "Text"], Cell["\<\ SetDirectory[$MCRoot<>$PathnameSeparator<>\"Demos\"<>$\ PathnameSeparator<>\"Gauss\"];\ \>", "Input"], Cell["Check whether this file is in the current directory.", "Text"], Cell["ExistFileQ[\"Gauss.nb\"];", "Input"], Cell["Off[General::spell1]", "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Start the Gauss Package", "Section"], Cell["BeginPackage[\"Gauss`\",{MathCodeContexts}];", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell["Define exported symbols", "Text"], Cell["\<\ Begin[\"Gauss`\"]; GaussSolveMatlab; GaussSolveForLoops; End[];\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[CellGroupData[{ Cell["Set compilation options", "Subsection"], Cell["\<\ Possibly set compilation options. In this case no extra options are \ needed.\ \>", "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["The body of the Gauss package", "Section"], Cell["Begin[\"`Private`\"];", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[CellGroupData[{ Cell["The GaussSolveMatlab function", "Subsection"], Cell["\<\ GaussSolveMatlab[Real[n_,n_]@ ain_, Real[n_,m_]@ bin_ , Integer@ iterations_ ]-> Real[n,m] := Module [ { Real[n]@ \tdumc, Real[n,n]@ \ta, Real[n,m]@ \tb, Integer[n]@ {ipiv, indxr, indxc}, Integer@ \t{i,k,l,irow,icol}, Real@ \t{pivinv, amax, tmp}, Integer@ \t{beficol, afticol, count} }, For[count=1,count<=iterations,count=count+1,( a=ain; (* The arguments are always generated as const references and therefore cannot be changed. Actuall we get waste of space and time here when we copy them. \ *) b=bin; For [k=1,k<=n, k=k+1,ipiv[[k]]=0]; (* ipiv=0; - goes well with code generator but fails in Generated \ Mathematica mode *) For [i=1,i<=n, i=i+1, (* Algorithm first finds absolutely largest matrix element *) amax=0.0; For [k=1,k<=n, k=k+1, If [ ipiv[[k]]==0 , For [l=1,l<=n, l=l+1, If [ ipiv[[l]]==0 , If [ Abs[a[[k,l]]] > amax, amax= Abs[a[[k,l]]]; irow=k; icol=l ]]]]]; (* Abs is generated as LIGHTABS , a macro in lightmat.h *) ipiv[[icol]]=ipiv[[icol]]+1; (* shortcut wanted, like ipiv[[icol]]+=1 \ *) If[ipiv[[icol]]>1, \"*** Gauss2 input data error ***\">>\"\"; Break]; If[ irow!=icol , For [k=1,k<=n, k=k+1, tmp=a[[irow,k]] ; (* Swap possibility wanted; have we? *) \ a[[irow,k]]=a[[icol,k]]; a[[icol,k]]=tmp]; For [k=1,k<=m, k=k+1, tmp=b[[irow,k]] ; b[[irow,k]]=b[[icol,k]]; b[[icol,k]]=tmp] ]; indxr[[i]]=irow; indxc[[i]]=icol; If [ a[[icol,icol]]==0, Print[\"*** Gauss2 input data error 2 ***\"]; Break]; pivinv=1.0 / a[[icol,icol]]; a[[icol,icol]]=1.0; a[[icol,_]]=a[[icol,_]]*pivinv; b[[icol,_]]=b[[icol,_]]*pivinv; dumc=a[[_,icol]]; For [k=1,k<=n, k=k+1, a[[k,icol]]=0]; (* This cannot be simplified... \ *) a[[icol,icol]]= pivinv; For [k=1,k<=n, k=k+1, If [ k != icol, a[[k,_]]= a[[k,_]]- dumc[[k]]*a[[icol,_]]; b[[k,_]]= b[[k,_]]- dumc[[k]]*b[[icol,_]] ]] (* Note: OuterProd is not available in the current implementation. THIS IS A COMMENT, to be converted to code when OuterProd is available *) (* beficol=icol-1; afticol=icol+1; a[[1| beficol, _]]= a[[1| beficol,_]] - OuterProd[dumc[[1 | beficol]],a[[icol,_]]]; b[[1| beficol, _]]= b[[1| beficol, _]] - OuterProd[dumc[[1 | beficol]],b[[icol,_]]]; a[[afticol |_ ,_]]= a[[afticol |_ ,_]] - OuterProd[dumc[[afticol | _ ]],a[[icol,_]]]; b[[afticol |_ ,_]]= b[[afticol _, _]] - OuterProd[dumc[[afticol |_ ]],b[[icol,_]]] *) ]; (* Extra semicolons above are harmful *) (* This fragment is present in the original algorithm, but it is unclear why this is really needed *) For [l=n,l>=1, l=l-1, For [k=1,k<=n, k=k+1, tmp= a[[k,indxr[[l]]]]; a[[k,indxr[[l]]]]=a[[k,indxc[[l]]]]; a[[k,indxc[[l]]]]=tmp ]] )]; b ]; \ \>", "Input"] }, Open ]], Cell[CellGroupData[{ Cell["The GaussSolveForLoops function ", "Subsection"], Cell["\<\ GaussSolveForLoops[Real[n_,n_]@ ain_, Real[n_,m_]@ bin_ , Integer@ iterations_ ]-> Real[n,m] := Module [ { Real[n]@ \tdumc, Real[n,n]@ \ta, Real[n,m]@ \tb, Integer[n]@ {ipiv, indxr, indxc}, Integer@ \t{i, k, l, irow, icol}, Real@\t\t{pivinv, amax, tmp}, Integer@ \t{beficol, afticol, count} }, For[count=1,count<=iterations,count=count+1,( a=ain; (* The arguments are always generated as const references and therefore cannot be changed. Actuall we get waste of space and time here when we copy them. \ *) b=bin; For [k=1,k<=n, k=k+1,ipiv[[k]]=0]; (* ipiv=0; - goes well with code generator but fails in Generated \ Mathematica mode *) For [i=1,i<=n, i=i+1, (* Algorithm first finds absolutely largest matrix element *) amax=0.0; For [k=1,k<=n, k=k+1, If [ ipiv[[k]]==0 , For [l=1,l<=n, l=l+1, If [ ipiv[[l]]==0 , If [ Abs[a[[k,l]]] > amax, amax= Abs[a[[k,l]]]; irow=k; icol=l ]]]]]; (* Abs is generated as LIGHTABS , a macro in lightmat.h *) ipiv[[icol]]=ipiv[[icol]]+1; (* shortcut wanted, like ipiv[[icol]]+=1 \ *) If[ipiv[[icol]]>1, \"*** Gauss2 input data error ***\">>\"\"; Break]; If[ irow!=icol , For [k=1,k<=n, k=k+1, tmp=a[[irow,k]] ; (* Swap possibility wanted; have we? *) \ a[[irow,k]]=a[[icol,k]]; a[[icol,k]]=tmp]; For [k=1,k<=m, k=k+1, tmp=b[[irow,k]] ; b[[irow,k]]=b[[icol,k]]; b[[icol,k]]=tmp] ]; indxr[[i]]=irow; indxc[[i]]=icol; If [ a[[icol,icol]]==0, Print[\"*** Gauss2 input data error 2 ***\"]; Break]; pivinv=1.0 / a[[icol,icol]]; a[[icol,icol]]=1.0; For [k=1,k<=n, k=k+1, a[[icol,k]]=a[[icol,k]]*pivinv]; For [k=1,k<=m, k=k+1, b[[icol,k]]=b[[icol,k]]*pivinv]; For [k=1,k<=n, k=k+1, dumc[[k]]=a[[k,icol]];a[[k,icol]]=0]; a[[icol,icol]]= pivinv; For [k=1,k<=n, k=k+1, If [ k != icol, For [l=1,l<=n, l=l+1, a[[k,l]]= a[[k,l]]- dumc[[k]]* a[[icol,l]]]; For [l=1,l<=m, l=l+1, b[[k,l]]= b[[k,l]]- dumc[[k]]* b[[icol,l]]] ]] ]; (* Extra semicolons above are harmful *) (* Ths fragment is present in the original algorithm, but it is unclear why this is really needed *) For [l=n,l>=1, l=l-1, For [k=1,k<=n, k=k+1, tmp= a[[k,indxr[[l]]]]; a[[k,indxr[[l]]]]=a[[k,indxc[[l]]]]; a[[k,indxc[[l]]]]=tmp ]] )]; b ]; \ \>", "Input"], Cell["\<\ End[]; EndPackage[];\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm] }, Open ]], Cell[CellGroupData[{ Cell["Executing the interpreted version in Mathematica", "Subsection"], Cell["Create two ramdom matrices.", "Text"], Cell["\<\ a=Table[Random[],{10},{10}]; b=Table[Random[],{10},{2}];\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm] }, Open ]], Cell[CellGroupData[{ Cell["Run the Matlab version", "Subsection"], Cell[CellGroupData[{ Cell["\<\ s=(c=GaussSolveMatlab[a,b,1];)//Timing; meval=s[[1]]; Print[\"TIMING FOR NON-COMPILED VERSION= \",meval]; Dot[a,c] - b // MatrixForm\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ InterpretationBox[ \("TIMING FOR NON-COMPILED VERSION= \ "\[InvisibleSpace]\(2.51999999999998181`\ Second\)\), SequenceForm[ "TIMING FOR NON-COMPILED VERSION= ", Times[ 2.5199999999999818, Second]], Editable->False]], "Print"], Cell[BoxData[ TagBox[ RowBox[{"(", GridBox[{ {"2.22044604925031308`*^-16", \(-1.38777878078144567`*^-16\)}, {"1.11022302462515654`*^-16", \(-2.22044604925031308`*^-16\)}, {\(-1.11022302462515654`*^-16\), \(-2.22044604925031308`*^-16\)}, {\(-1.11022302462515654`*^-16\), \(-6.93889390390722837`*^-18\)}, {"0.`", \(-3.33066907387546962`*^-16\)}, {"1.11022302462515654`*^-16", \(-3.88578058618804789`*^-16\)}, {\(-5.5511151231257827`*^-17\), \(-1.31838984174237339`*^-16\)}, {\(-1.11022302462515654`*^-16\), \(-6.66133814775093924`*^-16\)}, {"2.22044604925031308`*^-16", "5.82867087928207183`*^-16"}, {\(-1.11022302462515654`*^-16\), \(-3.05311331771918048`*^-16\)} }], ")"}], (MatrixForm[ #]&)]], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Run the For-loop version", "Subsection"], Cell[CellGroupData[{ Cell["\<\ s=(c=GaussSolveForLoops[a,b,1];)//Timing; mevalFor=s[[1]]; Print[\"TIMING FOR NON-COMPILED VERSION (FOR-LOOPS)=\",mevalFor]; Dot[a,c] - b // MatrixForm\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ InterpretationBox[ \("TIMING FOR NON-COMPILED VERSION \ (FOR-LOOPS)="\[InvisibleSpace]\(2.1500000000000341`\ Second\)\), SequenceForm[ "TIMING FOR NON-COMPILED VERSION (FOR-LOOPS)=", Times[ 2.1500000000000341, Second]], Editable->False]], "Print"], Cell[BoxData[ TagBox[ RowBox[{"(", GridBox[{ {"2.22044604925031308`*^-16", \(-1.38777878078144567`*^-16\)}, {"1.11022302462515654`*^-16", \(-2.22044604925031308`*^-16\)}, {\(-1.11022302462515654`*^-16\), \(-2.22044604925031308`*^-16\)}, {\(-1.11022302462515654`*^-16\), \(-6.93889390390722837`*^-18\)}, {"0.`", \(-3.33066907387546962`*^-16\)}, {"1.11022302462515654`*^-16", \(-3.88578058618804789`*^-16\)}, {\(-5.5511151231257827`*^-17\), \(-1.31838984174237339`*^-16\)}, {\(-1.11022302462515654`*^-16\), \(-6.66133814775093924`*^-16\)}, {"2.22044604925031308`*^-16", "5.82867087928207183`*^-16"}, {\(-1.11022302462515654`*^-16\), \(-3.05311331771918048`*^-16\)} }], ")"}], (MatrixForm[ #]&)]], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Generation of C++ code", "Section"], Cell["\<\ The command CompilePackage translates the package to C++ code:\ \>", "Text"], Cell[CellGroupData[{ Cell["CompilePackage[\"Gauss\"]", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \("Successful compilation to C++: 3 function(s)"\)], "Print"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Building the executable", "Section"], Cell["\<\ Call MakeBinary to compile the generated C++ code and build the \ executable(s).\ \>", "Text"], Cell["MakeBinary[]", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm] }, Closed]], Cell[CellGroupData[{ Cell["Installing compiled code", "Section"], Cell["\<\ Interpreted versions are removed, and compiled ones are used \ instead: (?? This should be updated. Use Activate and UnActivate instead. \ should not need to remove interpreted versions )\ \>", "Text"], Cell[CellGroupData[{ Cell["InstallCode[\"Gauss\"]", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ InterpretationBox[\("Gauss"\[InvisibleSpace]" is installed."\), SequenceForm[ "Gauss", " is installed."], Editable->False]], "Print"], Cell[BoxData[ \(LinkObject["'./Gaussml.exe'", 11, 2]\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["External Execution", "Section"], Cell[CellGroupData[{ Cell["Preperations", "Subsection"], Cell["\<\ SetAttributes[AbsTime,HoldFirst]; AbsTime[x_] := Module[{start,res}, \t\tstart = AbsoluteTime[]; \t\tres=x; \t\t{(AbsoluteTime[]-start) Second,res} \t];\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell["\<\ Note: Too short loop time for reliable measurements, only 3- 4 \ seconds combined with a resolution of 1 second.\ \>", "Text"], Cell[CellGroupData[{ Cell["\<\ loops=8000; externaleval=((c=GaussSolveMatlab[a,b,loops]; )//AbsTime)[[1]]/loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.002374999999999999995`6.9983\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=750; externalevalPass=((Do[c=GaussSolveMatlab[a,b,1],{loops}];)//AbsTime)[[1]]/\ loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.01066666666666666669`6.6227\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=5000; externalevalFor=((c=GaussSolveForLoops[a,b,loops]; \ )//AbsTime)[[1]]/loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.00139999999999999999`6.5647\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=500; externalevalPassFor=((Do[c=GaussSolveForLoops[a,b,1],{loops}];)//AbsTime)[[1]]\ /loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.012`6.4977\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=32000; internalEval=((Do[c=LinearSolve[a,b],{loops}];)//AbsTime)[[1]]/loops\ \>", "Input"], Cell[BoxData[ \(0.000687500000000000014`7.062\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["Dot[a,c] - b // MatrixForm", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ TagBox[ RowBox[{"(", GridBox[{ {"0.`", \(-1.11022302462515654`*^-16\)}, {"1.11022302462515654`*^-16", \(-4.44089209850062616`*^-16\)}, {"1.11022302462515654`*^-16", \(-2.22044604925031308`*^-16\)}, {\(-1.11022302462515654`*^-16\), \(-1.17961196366422882`*^-16\)}, {\(-3.33066907387546962`*^-16\), "3.33066907387546962`*^-16"}, {"0.`", \(-4.99600361081320443`*^-16\)}, {"4.44089209850062616`*^-16", "9.02056207507939689`*^-17"}, {"0.`", "0.`"}, {"0.`", \(-3.05311331771918048`*^-16\)}, {"1.66533453693773481`*^-16", "1.38777878078144567`*^-16"} }], ")"}], (MatrixForm[ #]&)]], "Output"] }, Open ]], Cell["\<\ UninstallCode[\"Gauss\"]; Map[DeleteFile,FileNames[\"*.o\"]];Map[DeleteFile,FileNames[\"*.obj\"]];Map[\ DeleteFile,FileNames[\"*.exe\"]];\ \>", "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Inline C++ Compilation", "Section"], Cell["\<\ Inline compilation will make matrix operations inline. This will improve \ performance of computation. The drawbacks are increased compilation time and \ size of the binary code.\ \>", "Text"], Cell["MakeBinary[InlineFlag->True]", "Input"], Cell[CellGroupData[{ Cell["InstallCode[\"Gauss\"];", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ InterpretationBox[\("Gauss"\[InvisibleSpace]" is installed."\), SequenceForm[ "Gauss", " is installed."], Editable->False]], "Print"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=8000; ILexternaleval=((c=GaussSolveMatlab[a,b,loops]; )//AbsTime)[[1]]/loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.00212499999999999999`6.95\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=750; ILexternalevalPass=((Do[c=GaussSolveMatlab[a,b,1],{loops}];)//AbsTime)[[1]]/\ loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.01066666666666666669`6.6227\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=5000; ILexternalevalFor=((c=GaussSolveForLoops[a,b,loops]; \ )//AbsTime)[[1]]/loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.0012`6.4977\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=500; ILexternalevalPassFor=((Do[c=GaussSolveForLoops[a,b,1],{loops}];)//AbsTime)[[\ 1]]/loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.01`6.4185\ Second\)], "Output"] }, Open ]], Cell["\<\ UninstallCode[\"Gauss\"]; Map[DeleteFile,FileNames[\"*.o\"]];Map[DeleteFile,FileNames[\"*.obj\"]];Map[\ DeleteFile,FileNames[\"*.exe\"]];\ \>", "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Inline, without range check C++ Compilation", "Section"], Cell["\<\ Inline compilation will make matrix operations inline. This will \ improve performance of computation. The drawbacks are increased compilation \ time and size of the binary code.\ \>", "Text"], Cell["MakeBinary[InlineFlag->True,RangeCheckFlag->False]", "Input"], Cell[CellGroupData[{ Cell["InstallCode[\"Gauss\"];", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ InterpretationBox[\("Gauss"\[InvisibleSpace]" is installed."\), SequenceForm[ "Gauss", " is installed."], Editable->False]], "Print"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=32000; RLexternaleval=((c=GaussSolveMatlab[a,b,loops]; )//AbsTime)[[1]]/loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.001656250000000000007`7.4438\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=1000; RLexternalevalPass=((Do[c=GaussSolveMatlab[a,b,1],{loops}];)//AbsTime)[[1]]/\ loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.00900000000000000002`6.6738\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=32000; RLexternalevalFor=((c=GaussSolveForLoops[a,b,loops]; \ )//AbsTime)[[1]]/loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.001062500000000000022`7.251\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ loops=500; RLexternalevalPassFor=((Do[c=GaussSolveForLoops[a,b,1],{loops}];)//AbsTime)[[\ 1]]/loops\ \>", "Input", PageWidth->Infinity, ShowSpecialCharacters->False, FormatType->InputForm], Cell[BoxData[ \(0.012`6.4977\ Second\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(a . c - b\)], "Input"], Cell[BoxData[ \({{2.22044604925031308`*^-16, \(-1.38777878078144567`*^-16\)}, { 1.11022302462515654`*^-16, \(-2.22044604925031308`*^-16\)}, { \(-1.11022302462515654`*^-16\), \(-2.22044604925031308`*^-16\)}, { \(-1.11022302462515654`*^-16\), \(-6.93889390390722837`*^-18\)}, { 0.`, \(-3.33066907387546962`*^-16\)}, {1.11022302462515654`*^-16, \(-3.88578058618804789`*^-16\)}, {\(-5.5511151231257827`*^-17\), \(-1.31838984174237339`*^-16\)}, {\(-1.11022302462515654`*^-16\), \(-6.66133814775093924`*^-16\)}, {2.22044604925031308`*^-16, 5.82867087928207183`*^-16}, {\(-1.11022302462515654`*^-16\), \(-3.05311331771918048`*^-16\)}}\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Performance Comparison", "Section"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"TableForm", "[", RowBox[{ RowBox[{"(", GridBox[{ {"meval", \(meval/RLexternaleval\)}, {"mevalFor", \(mevalFor/RLexternaleval\)}, {"\"\\"", "\"\\""}, {"externalevalPass", \(externalevalPass/RLexternaleval\)}, {"externalevalPassFor", \(externalevalPassFor/RLexternaleval \.18\)}, {"externaleval", \(externaleval/RLexternaleval\)}, {"externalevalFor", \(externalevalFor/RLexternaleval\)}, {"ILexternalevalPass", \(ILexternalevalPass/RLexternaleval\)}, {"ILexternalevalPassFor", \(ILexternalevalPassFor/RLexternaleval\)}, {"ILexternaleval", \(ILexternaleval/RLexternaleval\)}, {"ILexternalevalFor", \(ILexternalevalFor/RLexternaleval\n\t \)}, {"RLexternalevalPass", \(RLexternalevalPass/RLexternaleval\)}, {"RLexternalevalPassFor", \(RLexternalevalPassFor/RLexternaleval\)}, {"RLexternaleval", \(RLexternaleval/RLexternaleval\)}, {"RLexternalevalFor", \(RLexternalevalFor/RLexternaleval\)}, {"internalEval", \(internalEval/RLexternaleval\)} }], ")"}], " ", ",", \(TableHeadings -> {{"\", "\<- GaussLoop with For loops\>", "\", "\", "\<- GaussLoop with For loops + call overhead\>", "\", \ "\<- GaussLoop with For loops\>", "\", "\<- GaussLoop with For loops + call overhead, Inline\>", "\", "\<- GaussLoop with For loops, Inline\>", \n\t\t\t "\", "\<- GaussLoop with For loops + call overhead, No range \ check\>", "\", "\<- GaussLoop with For loops, No range check\>", "\"}, {"\