Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Speed of dot product in Mathematica

  • To: mathgroup at
  • Subject: [mg5317] Re: [mg5230] Speed of dot product in Mathematica
  • From: carlos at mars.Colorado.EDU (Carlos A. Felippa)
  • Date: Wed, 27 Nov 1996 01:47:35 -0500
  • Organization: University of Colorado, Boulder
  • Sender: owner-wri-mathgroup at

In article <56p225$m3c at> BobHanlon at writes:
>You can also use
>Plus @@ (a b)
>If you want the dot product of portions of the factors, use only the
>portions.  For example,
>Take[a, {100, 1000}].Take[b, {200, 1100}]

Of course I use Take where possible. The following skyline
factorization module is an example.

SymmSkyMatrixFactor[S_,tol_]:= Module[
  row=SymmSkyMatrixRowLengths[S]; s=Max[row];
  {p,a}=S; n=Length[p]-1; v=Table[0,{n}]; fail=0;
  Do [jj=p[[j+1]]; If [jj<0|row[[j]]==0, Continue[]]; d=a[[jj]]; 
      jmj=Abs[p[[j]]]; jk=jj-jmj;
     Do [i=j-jk+k; v[[k]]=0; ii=p[[i+1]];
        If [ii<0, Continue[]]; m=Min[ii-Abs[p[[i]]],k]-1;
            ij=jmj+k; v[[k]]=a[[ij]];
      If [Abs[d]<tol*row[[j]], fail=j; a[[jj]]=Infinity; Break[] ]; 
However, the dot product cannot always be done using unit strides
in both arrays, and use of Sum, Do or For exert big speed penalties.
To overcome that problem I once tried the form

but that was rejected as illegal.   It seems an unreasonable
restriction for the Take function.

  • Prev by Date: maple -> mathematica software?
  • Next by Date: Re: Formatting Output
  • Previous by thread: Re: Speed of dot product in Mathematica
  • Next by thread: Re: SeedRandom oddity/flaw/bug/imperfection