[R] Understanding dsyrk_ in C code
Charles C. Berry
cberry at tajo.ucsd.edu
Wed Jan 7 07:04:43 CET 2009
On Wed, 7 Jan 2009, Nathan S. Watson-Haigh wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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.
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
>
> - --
> - --------------------------------------------------------
> 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
>
> iEYEARECAAYFAklkGVYACgkQ9gTv6QYzVL73HgCgvx4OCxcuczv8nd0n6gOEPFYa
> w3UAnAnDIkvPDen9p7ahz+BdG47V/D/S
> =gSGC
> -----END PGP SIGNATURE-----
>
> ______________________________________________
> 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
More information about the R-help
mailing list