[R] Understanding dsyrk_ in C code

Nathan S. Watson-Haigh nathan.watson-haigh at csiro.au
Wed Jan 7 07:13:01 CET 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Charles C. Berry wrote:
> On Wed, 7 Jan 2009, Nathan S. Watson-Haigh wrote:
> 
> I'm trying to understand some C code in an R package I'm using. I'm address this question here as
> it's matrix algebra...and I'm no pro at that!
> 
> the C command reads:
> 
> double alpha = 1.0, beta = 0.0;
> dsyrk_("L", "N", nGenes, nGenes, & alpha, mat1, nGenes,
>         & beta, mat2, nGenes);
> 
>> That's a Fortran subroutine. The code is in blas.f (as 'DSYRK') and is 
>> commented. So, you should be able to work thru it.
> 
>> If you want to see how it is used, grep the sources for 'dsyrk' (lower 
>> case). I think array.c uses it for symmetric crossproducts along the lines 
>> of the alpha=1.0 and beta = 0.0 example you cite.
> 
>> It is often a good idea to search the R sources for routines whose 
>> function is puzzling and find examples of their use to help one understand 
>> what they do.

Thanks! I'll have a look through that tomorrow.

Cheers,
Nath

> 
>> HTH,
> 
>> Chuck
> 
> - From google, I've found out that dsyrk is for performing one of the symmetric rank k operations -
> whatever that means!? From here:
> http://linux.die.net/man/l/dsyrk
> 
> I've found that the calculation being performed is:
> alpha*A*A' + beta*C
> 
> However, since alpha is 1 and beta is 0, this reduces to:
> => 1*A*A' + 0*C
> => A*A'
> 
> Which is simply the cross product....am I correct?
> 
> Cheers,
> Nath
> 
>>
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
>>

> Charles C. Berry                            (858) 534-2098
>                                              Dept of Family/Preventive Medicine
> E mailto:cberry at tajo.ucsd.edu	            UC San Diego
> http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901




- --
- --------------------------------------------------------
Dr. Nathan S. Watson-Haigh
OCE Post Doctoral Fellow
CSIRO Livestock Industries
Queensland Bioscience Precinct
St Lucia, QLD 4067
Australia

Tel: +61 (0)7 3214 2922
Fax: +61 (0)7 3214 2900
Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html
- --------------------------------------------------------

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklkR+0ACgkQ9gTv6QYzVL64rQCeJPNFiJ6bznKWnP+evlzXwOxJ
bY0An3Lnq6PzPdeQDisJ5jhnyPshYcAI
=5UNy
-----END PGP SIGNATURE-----




More information about the R-help mailing list