slach is a simple linear algebra libraries desigined for low-coupling used C89, and it is convient for portability. slach has main parts: base, operation, QR decomposition, LU decomposition, SVD decomposition and Fast Fourier Transform(FFT). All other parts except for base all depend on base, rather than compelx dependency. If users want to just use the library, the users don't need to know inner data structures, instead you can use arraies to achieve results. If users want to implement the algorithms, it's easy to transfer programs. In the program, I seperate the inner and outer clearly, so a lot of wrapper functions employed in the program.
The interface of slach basically like:
float* srcsize_t row,size_t colORsize_t lenfloat* destsize_t height,size_t widthORsize_t len- other paramaters
The meaning is: use this function on src and save in dest.
base declares and defines basic data structures: vector and matrix, it can be easily used in other applications. base also defines some utilities: safe malloc and free, print function and random numbers generation.
MatrixandVectorprovide some basic functions: create, destroy, deep copy, array to matrix, matrix to array, vector to array, array to vector.slach_mallocandslach_freeare safe memory control functions.slach_rand_seedsets rand seed,slach_rand_int_range_*generates integer r.v. in different range,uRandgenerates uniform distribution,gaussrandgenerates Gaussian distribution,expRandgenerates exponential distribution.perrprint error and exit program,print*print vectors and matrices.
operation declares and defines operation functions: element-wise math function, matrix multiplication, add, transpose, vector inner product, vector l-p norm and matrix norm, slice like matlab.
*mand*vare element-wise math functions.slicevandslicemdo slice like matlab.mmMul,mvMul,mmAdd,vvAdd,dot,vnormandmnormdo matrix multiplication, add, transpose, vector inner product, vector l-p norm and matrix norm.
LUD implements LU decomposition, and offers LUD interface, solving linear equations using LUD and matrix inverse using LUD.
getLandgetUgetLandUmatrix.LUsolvemandLUsolvevsolve linear equations: AX=b, AX=Binvinverse square matrix using LU decomposition.
QRD implements QR decomposition, and offers QRD interface, solving linear equations using QRD.
getQandgetRgetQandRmatrix.QRsolvemandQRsolvevsolve linear equations: AX=b, AX=B
SVD implements SVD decomposition, and offers SVD interface. And also we can do eigenvalue decomposition using SVD.
getS, getV and getUs get S vector, V and U matrix.
FFT implements naive Discrete Fourier Transform and Cooley-Turkey FFT. Besides, we provide abs and phase using FFT--often we use in reality is abs and pahse after FFT. And we also provide DFT_naive and FFT_CooleyTukey.
fftAbsandfftPhasedo FFT and then calculate abs and pahse.DFT_naiveandFFT_CooleyTukeyreturn complex value of FFT.fftshiftdo like matlabfftshift.