/* This is an C++ version of multA.m which can be dynamically linked with Octave using the command mkoctfile multA.cc It performs the same functions as multA.m except 30 times faster when n=10000 on my machine. For n>10000 it is likely that a cache blocked algorithm would be necessary. Note that Matlab has a similar ability to dynamically link C++ code; however, the Matlab version of multA.m on the UNR Citrix server was already fast enough. Written 2005 by Eric Olson for MATH/CS 466/666 */ #include DEFUN_DLD (multA, args, , "% multA.m -- Multiply a vector by a matrix\n\n" "function y=multA(x)\n" " n=length(x);\n" " c=[-1.0./[n-1:-1:1].^2,5,-1.0./[1:n-1].^2];\n" " for i=n:-1:1\n" " y(i,1)=c(n-i+1:2*n-i)*x;\n" " end" ){ ColumnVector x(args(0).vector_value ()); int n=x.length(); { ColumnVector y(n); for(int i=0;i