Re: What maximal productivity for work under Matlab 7
- From: vitalybn <resampling@xxxxxxxxx>
- Date: Fri, 21 Oct 2005 14:08:11 -0400
Ok. It is not correct.
This is my last version:
A=double(rand(1500,3000));
B=double(rand(3000,1500));
tic; C=(A'*A)\B; toc
In reality A and B matrix not a random!
In my last version code - A and B random jast for short lenth of the
code and easy to understand. On a speed - random matrixs is not
depend.
In My computer (last code) toc = 58 sec.
How I can optimization last version code?
Thank you for help my.
John D'Errico wrote:
>
>
> In article <ef18ee0.1@xxxxxxxxxxxxxxxx>,
> Vitalybn <resampling@xxxxxxxxx> wrote:
>
>> My program work with similar matrixes on the size. And in a
cycle
>> does this operation some thousand times. For acceleration of
work
> of
>> this program the fastest computer is necessary to me. Speed of
>> performance of this operation for me it is the most important.
> For
>> work of this program the new computer is necessary to me. FFT,
> 3D,
>> (bench) for me it is unimportant.
>>
>> John D'Errico wrote:
>> >
>> >
>> > In article <ef18ee0.-1@xxxxxxxxxxxxxxxx>,
>> > Vitalybn <resampling@xxxxxxxxx> wrote:
>> >
>> >> This is my code:
>> >>
>> >> A=double(rand(1,3000));
>> >> B=double(rand(3000,1));
>> >> tic; C=(A'*A)\B; toc
>
> No, no, no. You have not understood the gist of my
> response. Lets look at the problem you have posed.
>
> If A is a row vector, then the linear system
>
> (A'*A)*x = B
>
> involves the matrix A'*A. Lets take it apart. This
> matrix has an eigenvalue decomposition
>
> P*D*P' = A'*A
>
> where there is only 1 non-zero eigenvalue. All the
> other eigenvalues are zero. The eigenvector is
>
> A'./norm(A)
>
> and the non-zero eigenvalue is norm(A)^2.
>
> Now, when I multiply A'*A times any vector x, any
> component in the direction of the zero eigenvalue
> eigenvectors will be killed off. So the solution
> vector x to this problem will be just a multiple
> of A'.
>
> What is the resulting solution?
>
> x = A'.*(dot(A,B)/norm(A)^4);
>
> We can look at an example system. I'll use a small
> one initially, since size is irrelevant, only
> affecting the speed.
>
> A=double(rand(1,10));
> B=double(rand(10,1));
>
> Now, lets look at what \ does:
>
> C=(A'*A)\B
> Warning: Matrix is close to singular or badly scaled.
> Results may be inaccurate. RCOND = 3.514434e-20.
>
> C =
> 1.0e+18 *
>
> 0.1889
> 0.2326
> -0.0783
> 2.6612
> -0.5730
> -0.3492
> 1.0105
> 0.0678
> -0.1550
> -0.4549
>
> Yes, we get crap, because A is truly massively
> singular. We can actually solve this rank 1 system
> using pinv, overkill that it is.
>
> C=pinv(A'*A)*B
> C =
> 0.2027
> 0.1523
> 0.1751
> 0.0230
> 0.1060
> 0.0937
> 0.0415
> 0.2079
> 0.2093
> 0.1127
>
> Using the dot product solution that I showed
> above,
>
> x = A'.*(dot(A,B)/norm(A)^4);
>
> [C,x]
>
> ans =
> 0.2027 0.2027
> 0.1523 0.1523
> 0.1751 0.1751
> 0.0230 0.0230
> 0.1060 0.1060
> 0.0937 0.0937
> 0.0415 0.0415
> 0.2079 0.2079
> 0.2093 0.2093
> 0.1127 0.1127
>
> The two solutions are indeed the same. Now, lets
> consider what the matrix system does in terms of
> system resources. It generates a huge (full) matrix
> A'*A that is 3000x3000. Then it factorizes that
> matrix using a cholesky factorization to solve
> the system, only to find out that the system is
> singular!
>
> A=double(rand(1,3000));
> B=double(rand(3000,1));
>
> tic,C = (A'*A)\B;toc
>
> Warning: Matrix is close to singular or badly scaled.
> Results may be inaccurate. RCOND = 4.063765e-26.
> Elapsed time is 17.623990 seconds.
>
> tic,x=A'*dot(A,B)/norm(A)^4;toc
>
> Elapsed time is 0.002845 seconds.
>
>
> The speed difference is more than a factor of
> 6000 to 1. And the solution that I posed is finite,
> with no singularities at all.
>
> So after a long detour, lets return to your problem.
> You state that these are the kinds of problems that
> are important to you, not any of the other components
> of bench. This is exactly why I told you to save your
> money and buy an undergraduate linear algebra text.
> A 6000 to 1 speed bump is far more than you will get
> unless you are willing to buy a supercomputer.
>
> Unless you really just want an excuse to buy a new
> computer. Some of those new games do need the speed.
> Fast video cards are helpful too though.
>
> John
>
>
> --
> The best material model of a cat is another, or preferably the
> same, cat.
> A. Rosenblueth, Philosophy of Science, 1945
>
> Those who can't laugh at themselves leave the job to others.
> Anonymous
>
.
- Follow-Ups:
- Re: What maximal productivity for work under Matlab 7
- From: John D'Errico
- Re: What maximal productivity for work under Matlab 7
- References:
- What maximal productivity for work under Matlab 7
- From: Vitalybn
- Re: What maximal productivity for work under Matlab 7
- From: John D'Errico
- Re: What maximal productivity for work under Matlab 7
- From: Vitalybn
- What maximal productivity for work under Matlab 7
- Prev by Date: Re: .m FUNCTION to SIMULINK BLOCK
- Next by Date: Re: Matlab on a Mac: is it worth?
- Previous by thread: Re: What maximal productivity for work under Matlab 7
- Next by thread: Re: What maximal productivity for work under Matlab 7
- Index(es):
Relevant Pages
|