>> >> >> n=500*p n= 500p >> a=randn(n); >> a a = ddense object: 500-by-500 >> >> b=randn(n); >> tic, c=a*b; toc elapsed_time = 1.2323 >> n=n*2, a=randn(n); b=randn(n); c=randn(n); n= 1000p >> tic, c=a*b; toc elapsed_time = 1.4400 >> n=n*2, a=randn(n); b=randn(n); c=randn(n); n= 2000p >> tic, c=a*b; toc elapsed_time = 6.7935 >> n=n*2, a=randn(n); b=randn(n); c=randn(n); tic, c=a*b; toc n= 4000p elapsed_time = 41.3447 >> n=500*; ??? n=500*; | Error: Expected a variable, function, or constant, found ";". >> n=500*p n= 500p >> a=randn(n); tic, a=inv(a); toc elapsed_time = 1.2568 >> n=n*2,a=randn(n); tic, a=inv(a); toc n= 1000p elapsed_time = 3.9541 >> n=n*2,a=randn(n); tic, a=inv(a); toc n= 2000p elapsed_time = 17.2238 >> ,a=randn(n); tic, b=inv(a); toc elapsed_time = 16.9742 >> e=eye(n); >> c=a*b-e; >> c(1) ans = 1.1102e-15 >> c(2) ans = 9.9434e-15 >> sum(sum(c.^2)) ??? Undefined function or variable 'ppscope'. Error in ==> /usr/local/matlabp/@ddense/power.m On line 6 ==> s=ppscope; >> sum(sum(c.*c)) ans = ddense object: 1-by-1 >> ans(1) ans = 1.5184e-20 >> type norm norm is a built-in function. >> !vi ournorm.m [?1h="ournorm.m" [New File]~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~-- INSERT --function z=ournorm(a)z=sum(sum(a.&*a)); z=-- INSERT --ssum(sum(a.*a)); z=sqsum(sum(a.*a)); z=sqrsum(sum(a.*a)); z=sqrtsum(sum(a.*a));(sum(sum(a.*a));(sum(sum(a.*a))-- INSERT --);-- INSERT --z=z(1);:wq "ournorm.m" [New] 4L, 55C written [?1l> >> ournorm(a) ans = 1.9985e+03 >> ournorm(c) ans = 1.2322e-10 >> type ournorm function z=ournorm(a) z=sqrt(sum(sum(a.*a))); z=z(1); >> type hilb function H = hilb(n) %HILB Hilbert matrix. % HILB(N) is the N by N matrix with elements 1/(i+j-1), % which is a famous example of a badly conditioned matrix. % See INVHILB for the exact inverse. % % This is also a good example of efficient MATLAB programming % style where conventional FOR or DO loops are replaced by % vectorized statements. This approach is faster, but uses % more storage. % C. Moler, 6-22-91. % Copyright 1984-2001 The MathWorks, Inc. % $Revision: 5.9 $ $Date: 2001/04/15 12:02:29 $ % I, J and E are matrices whose (i,j)-th element % is i, j and 1 respectively. J = 1:n; J = J(ones(n,1),:); I = J'; E = ones(n,n); H = E./(I+J-1); >> hilb(3) ans = 1.0000 0.5000 0.3333 0.5000 0.3333 0.2500 0.3333 0.2500 0.2000 >> hilb(7) ans = 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.0909 0.1667 0.1429 0.1250 0.1111 0.1000 0.0909 0.0833 0.1429 0.1250 0.1111 0.1000 0.0909 0.0833 0.0769 >> type hilb function H = hilb(n) %HILB Hilbert matrix. % HILB(N) is the N by N matrix with elements 1/(i+j-1), % which is a famous example of a badly conditioned matrix. % See INVHILB for the exact inverse. % % This is also a good example of efficient MATLAB programming % style where conventional FOR or DO loops are replaced by % vectorized statements. This approach is faster, but uses % more storage. % C. Moler, 6-22-91. % Copyright 1984-2001 The MathWorks, Inc. % $Revision: 5.9 $ $Date: 2001/04/15 12:02:29 $ % I, J and E are matrices whose (i,j)-th element % is i, j and 1 respectively. J = 1:n; J = J(ones(n,1),:); I = J'; E = ones(n,n); H = E./(I+J-1); >> >> c=hilb(6*p) c = ddense object: 6-by-6 >> c(:,:) ans = 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.1667 0.1429 0.1250 0.1111 0.1000 0.0909 >> c(:,:)-hilb(6) ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> c3 = c*c*c; >> c3(:,:)-hilb(6)^3 ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> c6 = c*c*c*c*c*c; >> c c = ddense object: 6-by-6 >> c6(:,:)-hilb(6)^6 ans = 1.0e-15 * 0 -0.8882 -0.8882 -0.4441 -0.4441 0 0.8882 0 0 0.4441 0.2220 0.2220 0.8882 0 -0.2220 0.2220 0 0 0 0 0 0 0 0 0 0 -0.2220 0 0 0.1110 0 0 -0.2220 0 0 0 >> c c = ddense object: 6-by-6 >> c6 = c*c*c*c*c*c; >> c6 c6 = ddense object: 6-by-6 >> c6(:,:) ans = 10.0916 5.9401 4.3224 3.4277 2.8511 2.4455 5.9401 3.4966 2.5444 2.0177 1.6783 1.4395 4.3224 2.5444 1.8515 1.4682 1.2212 1.0475 3.4277 2.0177 1.4682 1.1643 0.9684 0.8307 2.8511 1.6783 1.2212 0.9684 0.8055 0.6910 2.4455 1.4395 1.0475 0.8307 0.6910 0.5927 >> c6(:,:)-hilb(6)^6 ans = 1.0e-15 * 0 -0.8882 -0.8882 -0.4441 -0.4441 0 0.8882 0 0 0.4441 0.2220 0.2220 0.8882 0 -0.2220 0.2220 0 0 0 0 0 0 0 0 0 0 -0.2220 0 0 0.1110 0 0 -0.2220 0 0 0 >> >> >> b=randn(n,1); >> n n= 2000p >> a=randn(n); >> a a = ddense object: 2000-by-2000 >> b b = ddense object: 2000-by-1 >> c=a\b; >> residual = a*c-b residual = ddense object: 2000-by-1 >> ournorm(residual) ans = 1.6432e-11 >> !vi f.m [?1h="f.m" [New File]~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~-- INSERT --function z=sumour_new_norm_sort_of(r)z=sum,(r.^2);:wq "f.m" [New] 3L, 49C written [?1l> >> b=mm('our_new_norm_sort_of',residual) Warning: One or more output arguments not assigned during call to 'ppclient'. > In /usr/local/matlabp/mm.m at line 29 Warning: Reference to uninitialized variable outmat in mm at line 31. > In /usr/local/matlabp/mm.m at line 31 ??? Error using ==> mm Cyclic distribution is not supported as an output >> >> >> a=randn(2000*p); >> >> >> a=randn(2000*p,2000); >> b=randn(2000*p,1); >> x=a\b; >> residual=a*x-b; >> ournorm(residual) ans = 4.0697e-11 >> b=mm('our_new_norm_sort_of',residual) Warning: One or more output arguments not assigned during call to 'ppclient'. > In /usr/local/matlabp/mm.m at line 29 Warning: Reference to uninitialized variable outmat in mm at line 31. > In /usr/local/matlabp/mm.m at line 31 ??? Error using ==> mm At least one of the MATLAB processes returned NULL output. It is very likely that your MATLAB script passed into mm contains error. Check MATLAB*P log for clue. >> type our_new_norm_sort_of ??? Error using ==> type our_new_norm_sort_of.m: File not found. >> ls ans = 020603 examples hw1.html ournorm.m sma Desktop f.m matlabp.log sdp timings >> b=mm('f',residual) b = ddense object: 4-by-1 >> np ans = 4 >> b b = ddense object: 4-by-1 >> b(1:4) ans = 1.0e-21 * 0.4006 0.0000 0.0000 0.0000 >> sum(ans) ans = 4.0061e-22 >> >> >> type f function z=our_new_norm_sort_of(r) z=sum(r.^2); >> atan(1)*4 ans = 3.1416 >> dx=.01; >> x=0:dx:(1-dx); >> sum( 1./(1+x.^2))*dx * 4 ans = 3.1516 >> x=0:dx:(1-dx)*p; >> x x = ddense object: 1-by-100 >> dx dx = 0.0100 >> dx=dx*p dx= 0.01p >> x=0:dx:(1-dx); >> x x = ddense object: 1-by-100 >> x=x/10 x = ddense object: 1-by-100 >> dx=dx/10 dx= 0.001p >> x=0:dx:(1-dx) x = ddense object: 1-by-1000 >> dx=dx/100; >> x=0:dx:(1-dx) x = ddense object: 1-by-100000 >> dx=dx/100; >> x=0:dx:(1-dx) x = ddense object: 1-by-10000000 >> dx=dx*100; >> x=0:dx:(1-dx) x = ddense object: 1-by-100000 >> sum( 1./(1+x.*x))* dx* 4 ans = 4 >> sum( 1./(1+x.*x)) ans = ddense object: 1-by-1 >> dx.n ??? Access to an object's fields is only permitted within its methods. >> dx(1) ans= 1e-05p >> abs(dx) ans = 1.0000e-05 >> sum( 1./(1+x.*x))* abs(dx) * 4 ans = 4 >> sum( 1./(1+x.*x)) ans = ddense object: 1-by-1 >> ans(1) ans = 100000 >> size(x) ans= 1 100000p >> sum( ones(size(x))./(1+x.*x)) ??? Error using ==> == Too many input arguments. Error in ==> /usr/local/matlabp/@layoot/ones.m On line 6 ==> if varargin{1}.p == 'p' >> sum( (0*x+1) ./(1+x.*x)) ans = ddense object: 1-by-1 >> ans(1) ans = 100000 >> !vi g.m \[?1h="g.m" [New File]~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~-- INSERT --function g(a,b),dx);x=a:dx:bl(b-dx);y= x1./(1+x.^2);function -- INSERT --Ig(a,b,dx);=g(a,b,dx); -- INSERT --MI-- INSERT --=sum(y)*dx;:wq "g.m" [New] 6L, 68C written [?1l> >> >> np ans = 4 >> a=(0:(np-1))/np a = 0 0.2500 0.5000 0.7500 >> a=(0*p:(np-1))/np a = ddense object: 1-by-4 >> a(1:4) ans = 0 0.2500 0.5000 0.7500 >> b=a+1/np b = ddense object: 1-by-4 >> b(1:4) ans = 0.2500 0.5000 0.7500 1.0000 >> I=mm('g',a,b, .01) I = ddense object: 1-by-4 >> sum(I)*4 ans = 3.1516 >> I=mm('g',a,b, .001) I = ddense object: 1-by-4 >> sum(I)*4 ans = 3.1426 >> I=mm('g',a,b, .0001) I = ddense object: 1-by-4 >> sum(I)*4 ans = 3.1417 >> I=mm('g',a,b, .00001) I = ddense object: 1-by-4 >> format long >> sum(I)*4 ans = 3.14160265357312 >> pi ans = 3.14159265358979 >> I=mm('g',a,b, .000001) I = ddense object: 1-by-4 >> sum(I)*4 ans = 3.14159365358960 >> I=mm('g',a,b, .000001); sum(I)*4, pi ans = 3.14159365358960 ans = 3.14159265358979 >> I=mm('g',a,b, .0000001); sum(I)*4, pi ans = 3.14159275358977 ans = 3.14159265358979 >> I=mm('g',a,b, .000000001); sum(I)*4, pi Warning: One or more output arguments not assigned during call to 'ppclient'. > In /usr/local/matlabp/mm.m at line 29 Warning: Reference to uninitialized variable outmat in mm at line 31. > In /usr/local/matlabp/mm.m at line 31 ??? Error using ==> mm At least one of the MATLAB processes returned NULL output. It is very likely that your MATLAB script passed into mm contains error. Check MATLAB*P log for clue. >> >> >> !vi g.m [?1h="g.m" 6L, 68Cfunction I=g(a,b,dx); x=a:dx:(b-dx); y= 1./(1+x.^2); I=sum(y)*dx; ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~  ~ ~ ~-- INSERT --quadlo(:wq "g.m" 3L, 30C written [?1l> >> help quadl QUADL Numerically evaluate integral, adaptive Lobatto quadrature. Q = QUADL(FUN,A,B) tries to approximate the integral of function FUN from A to B to within an error of 1.e-6 using high order recursive adaptive quadrature. The function Y = FUN(X) should accept a vector argument X and return a vector result Y, the integrand evaluated at each element of X. Q = QUADL(FUN,A,B,TOL) uses an absolute error tolerance of TOL instead of the default, which is 1.e-6. Larger values of TOL result in fewer function evaluations and faster computation, but less accurate results. [Q,FCNT] = QUADL(...) returns the number of function evaluations. QUADL(FUN,A,B,TOL,TRACE) with non-zero TRACE shows the values of [fcnt a b-a Q] during the recursion. QUADL(FUN,A,B,TOL,TRACE,P1,P2,...) provides for additional arguments P1, P2, ... to be passed directly to function FUN, FUN(X,P1,P2,...). Pass empty matrices for TOL or TRACE to use the default values. Use array operators .*, ./ and .^ in the definition of FUN so that it can be evaluated with a vector argument. Function QUAD may be more efficient with low accuracies or nonsmooth integrands. Example: FUN can be specified three different ways. A string expression involving a single variable: Q = quadl('1./(x.^3-2*x-5)',0,2); An inline object: F = inline('1./(x.^3-2*x-5)'); Q = quadl(F,0,2); A function handle: Q = quadl(@myfun,0,2); where myfun.m is an M-file: function y = myfun(x) y = 1./(x.^3-2*x-5); See also QUAD, DBLQUAD, INLINE, @. >> >> quadl('1./(1+x.^2)',0,1)*4 ans = 3.14159270703219 >> [a,b]=quadl('1./(1+x.^2)',0,1)*4 ??? Error: The 'mtimes' operator may only produce a single output. >> [a,b]=quadl('1./(1+x.^2)',0,1) a = 0.78539817675805 b = 18 >> a*4 ans = 3.14159270703219 >> help quadl QUADL Numerically evaluate integral, adaptive Lobatto quadrature. Q = QUADL(FUN,A,B) tries to approximate the integral of function FUN from A to B to within an error of 1.e-6 using high order recursive adaptive quadrature. The function Y = FUN(X) should accept a vector argument X and return a vector result Y, the integrand evaluated at each element of X. Q = QUADL(FUN,A,B,TOL) uses an absolute error tolerance of TOL instead of the default, which is 1.e-6. Larger values of TOL result in fewer function evaluations and faster computation, but less accurate results. [Q,FCNT] = QUADL(...) returns the number of function evaluations. QUADL(FUN,A,B,TOL,TRACE) with non-zero TRACE shows the values of [fcnt a b-a Q] during the recursion. QUADL(FUN,A,B,TOL,TRACE,P1,P2,...) provides for additional arguments P1, P2, ... to be passed directly to function FUN, FUN(X,P1,P2,...). Pass empty matrices for TOL or TRACE to use the default values. Use array operators .*, ./ and .^ in the definition of FUN so that it can be evaluated with a vector argument. Function QUAD may be more efficient with low accuracies or nonsmooth integrands. Example: FUN can be specified three different ways. A string expression involving a single variable: Q = quadl('1./(x.^3-2*x-5)',0,2); An inline object: F = inline('1./(x.^3-2*x-5)'); Q = quadl(F,0,2); A function handle: Q = quadl(@myfun,0,2); where myfun.m is an M-file: function y = myfun(x) y = 1./(x.^3-2*x-5); See also QUAD, DBLQUAD, INLINE, @. >> vvv ??? Undefined function or variable 'vvv'. >> [a,b]=quadl('1./(1+x.^2)',0,1,1e-14)) ??? [a,b]=quadl('1./(1+x.^2)',0,1,1e-14)) | Error: Missing operator, comma, or semicolon. >> [a,b]=quadl('1./(1+x.^2)',0,1,1e-14) a = 0.78539816339745 b = 138 >> a*4 ans = 3.14159265358979 >> !vi g.m [?1h="g.m" 3L, 30Cfunction I=g(a,b,dx); quadl( ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ quadl-- INSERT --a,b,1e-13);-- INSERT ---- INSERT --O)-- INSERT --O1-- INSERT --Oe-- INSERT --O,-- INSERT --O,Oa-- INSERT --Ol-- INSERT --OaOu -- INSERT --Oq-- INSERT --iquadl(a,b,1e-13); iIquadl(a,b,1e-13); iI=quadl(a,b,1e-13); iI=I=quadl(a,b,1e-13);I=:wq "g.m" 3L, 43C written [?1l> >> !vi g.m [?1h="g.m" 3L, 43Cfunction I=g(a,b,dx); I=quadl(a,b,1e-13); ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ I=quadl-- INSERT --'a,b,1e-13);1a,b,1e-13);.a,b,1e-13);/a,b,1e-13);(a,b,1e-13);1a,b,1e-13);+a,b,1e-13);xa,b,1e-13);.a,b,1e-13);^a,b,1e-13);2a,b,1e-13);)a,b,1e-13);'a,b,1e-13);,a,b,1e-13);:wq "g.m" 3L, 57C written [?1l> >> I=mm('g',a,b); ??? Error using ==> mm At least one argument must be ddense >> !vi g.m [?1h="g.m" 3L, 57Cfunction I=g(a,b,dx); I=quadl('1./(1+x.^2)',a,b,1e-13); ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~function I=g(a,b,dx);x););; -- INSERT --);:wq "g.m" 3L, 54C written [?1l> >> I=mm('g',a,b); ??? Error using ==> mm At least one argument must be ddense >> a a = 0.78539816339745 >> a=(0*p:(np-1))/np a = ddense object: 1-by-4 >> b=a+1/np b = ddense object: 1-by-4 >> I=mm('g',a,b); >> sum(I)*4 ans = 3.14159265358979 >> !vi g.m [?1h="g.m" 3L, 54Cfunction I=g(a,b); I=quadl('1./(1+x.^2)',a,b,1e-13); ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -- INSERT --[I=quadl('1./(1+x.^2)',a,b,1e-13); [[-- INSERT --1=quadl('1./(1+x.^2)',a,b,1e-13); [I1 =quadl('1./(1+x.^2)',a,b,1e-13); [I1 ,=quadl('1./(1+x.^2)',a,b,1e-13); [I1 , =quadl('1./(1+x.^2)',a,b,1e-13);I=quadl('1./(1+x.^2)',a,b,1e-13);2=quadl('1./(1+x.^2)',a,b,1e-13);]=quadl('1./(1+x.^2)',a,b,1e-13); =quadl('1./(1+x.^2)',a,b,1e-13);-- INSERT --I=[I1 I2];;:wq "g.m" 4L, 74C written [?1l> >> I=mm('g',a,b); >> I I = ddense object: 2-by-4 >> I(:) ans = 0.24497866312685 18.00000000000000 0.21866894587397 18.00000000000000 0.17985349979247 18.00000000000000 0.14189705460416 18.00000000000000 >> I(1:4,1:2) ??? Error using ==> ddense/gs Subscript out of range Error in ==> /usr/local/matlabp/@ddense/subsref.m On line 237 ==> y=gs(a,row,col); >> I(1:4,:) ??? Error using ==> ddense/gs Subscript out of range Error in ==> /usr/local/matlabp/@ddense/subsref.m On line 176 ==> y=gs(a,row,col); >> I(:,1:4) ans = 0.24497866312685 0.21866894587397 0.17985349979247 0.14189705460416 18.00000000000000 18.00000000000000 18.00000000000000 18.00000000000000 >> >> >> diary save