next up previous contents index
Next: Building and installing Sophya Up: sophya Previous: Module FitsIOServer   Contents   Index

LinAlg and IFFTW modules

An interface to use LAPACK library (available from http://www.netlib.org) is implemented by the LapackServer class, in module LinAlg. . The sample code below shows how to use SVD (Singular Value Decomposition) through LapackServer:

#include "intflapack.h"
// ...
// Use FortranMemoryMapping as default
BaseArray::SetDefaultMemoryMapping(BaseArray::FortranMemoryMapping);
// Create an fill the arrays A and its copy AA
int n = 20;
Matrix A(n , n), AA;
A = RandomSequence(RandomSequence::Gaussian, 0., 4.);  
AA = A;  // AA is a copy of A
// Compute the SVD decomposition
Vector S;  // Vector of singular values
Matrix U, VT;
LapackServer<r_8> lpks;
lpks.SVD(AA, S, U, VT);
// We create a diagonal matrix using S
Matrix SM(n, n); 
for(int k=0; k<n; k++) SM(k,k) = S(k);
// Check the result : A = U*SM*VT
Matrix diff = U*(SM*VT) - A;
double min, max;
diff.MinMax(min, max);
cout << " Min/Max difference Matrix (?=0) , Min= " << min 
     << " Max= " << max << endl;

The FFTWServer class (in module FFTW) implements FFTServerInterface class methods, for one dimensional and multi-dimensional Fourier transforms on double precision data using the FFTW package (available from http://www.fftw.org).



Reza Ansari
2001-03-07