Robertas Vilkas

44 Reputation

4 Badges

13 years, 27 days

MaplePrimes Activity


These are replies submitted by Robertas Vilkas

Using Threads package I've got some promising results, because it was the first time when my CPU was working at 83%:
Add function managed to consume 83% of CPU

But the time it used surprised me:

> restart;
   with(Threads):
   t:=time():
   Add((-i)^3, i=1..10^7);
   time()-t;
                                   -2500000500000025000000000000
                                                           15.078
> t:=time():
   add((-i)^3, i=1..10^7);
   time()-t;
                                   -2500000500000025000000000000
                                                            7.188
>

So, what's the point to use Add if it works slower? Moreover, add used only 25% of CPU (Add used up to 83% of CPU).

Despite the fact that my goal was achieved (for using more than 25% of CPU) it was all in vain. :)

I've got even more disappointment when I tried using threads myself:

> restart;
   with(Threads):
   loop:=proc(m)
      global n;
      local i,s;
      s:=0;
      for i from n*(m-1)/4 to n*m/4-1 do
         s:=s+i;
      end do;
      s;
   end proc:

> n:=10^7;
   id1 := Create(loop(1), s1);
   id2 := Create(loop(2), s2);
   id3 := Create(loop(3), s3);
   id4 := Create(loop(4), s4);
                                                            n := 10000000
                                                                 id1 := 1
                                                                 id2 := 2
                                                                 id3 := 3
                                                                 id4 := 4

> t:=time():
   Wait(id1,id2,id3,id4); 
   s1+s2+s3+s4+n;
   time()-t;
                                                          50000005000000
                                                                  20.063

> t:=time():
   add(k,k=0..n);
   time()-t;
                                                         50000005000000
                                                                    1.906
>
 

Maple 12 / help states this:
LinearAlgebra[IsDefinite]
- test for positive or negative definite or indefinite Matrices

Description
The IsDefinite(A, query = 'positive_definite') returns true if A is a real symmetric or a complex Hermitian Matrix and all the eigenvalues are determined to be positive. Because the default query is query = 'positive_definite', this command is equivalent to IsDefinite(A).


This description doesn't imply that IsDefinite(A) will always give true when matrix A is positive definite and not symmetric.

Question:
Is it just a bug in help description or we can't rely on function IsDefinite() for non symmetric matrices?
(I didn't find a counterexample, i.e. a non symmetric positive definite matrix A for which IsDefinite(A) = false)

Page 1 of 1