[Scilab-users] funny result for tensor norm calculation

Paul Carrico paul.carrico at free.fr
Wed Sep 26 19:42:18 CEST 2012


Dear All,

 

A funny result for calculating the norm of a tensor . for ounce a
"traditional" method (that probably uses vectorization in back stage) is
faster than the norm function .

 

Paul

 

mode(0);

 

A = [ 1 2 3 ; 4 5 6; 7 8 9]

n = 1000

for i = 1 : n

    for j = 1 : n

        B(i,j) = i*j;

    end

end

 

// Scilab function

tic();

norm(B)

t1 = toc()

 

// "traditional" method

// norm = sqrt(trace(A_transp * A))

tic

norm_ = (trace(B'*B))**0.5

t2 = toc()

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20120926/17ae31a2/attachment.htm>


More information about the users mailing list