[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Applying each element of a vector to each row of a matrix
From: |
Judd Storrs |
Subject: |
Re: Applying each element of a vector to each row of a matrix |
Date: |
Mon, 20 Dec 2010 08:57:40 -0500 |
On Mon, Dec 20, 2010 at 4:25 AM, Francesco Potortì <address@hidden> wrote:
> Using logarithms you can have exponentiation too. This still wins over
> bsxfun, even with the overhead of transform - antitransform:
Jaroslav added some optimizations to bsxfun in the developer sources
and they are closer in speed with bsxfun winning by a hair. The first
bsxfun evaluation is slower because bsxfun is an oct file that gets
loaded on first use (you can also use "help bsxfun" to load the module
and skip directly to the faster evaluations):
octave:1> n=30;a=repmat(1:n,n,1);
octave:2> tic;bsxfun(@power,a,(1:n)');toc
Elapsed time is 0.00258303 seconds.
octave:3> tic;bsxfun(@power,a,(1:n)');toc
Elapsed time is 0.000497103 seconds.
octave:4> tic;bsxfun(@power,a,(1:n)');toc
Elapsed time is 0.000482082 seconds.
octave:5> tic;exp(diag(1:n)*log(a));toc
Elapsed time is 0.000666142 seconds.
octave:6> tic;exp(diag(1:n)*log(a));toc
Elapsed time is 0.000509024 seconds.
octave:7> tic;exp(diag(1:n)*log(a));toc
Elapsed time is 0.000509977 seconds.
octave:8> version
ans = 3.3.54+
octave:9>
--judd
- Re: Applying each element of a vector to each row of a matrix, (continued)
- Re: Applying each element of a vector to each row of a matrix, Martin Helm, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Olaf Till, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jonathan Webster, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix, Jonathan Webster, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Judd Storrs, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Martin Helm, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Francesco Potortì, 2010/12/20
- Re: Applying each element of a vector to each row of a matrix,
Judd Storrs <=
- Re: Applying each element of a vector to each row of a matrix, Judd Storrs, 2010/12/19
- Re: Applying each element of a vector to each row of a matrix, Jordi Gutiérrez Hermoso, 2010/12/20
Re: Applying each element of a vector to each row of a matrix, Jaroslav Hajek, 2010/12/20