lu
Functions
lu_impls.c File Reference

Simple implementations of PLU factorization. More...

#include <stdio.h>
#include <math.h>
#include "lu_impls.h"
Include dependency graph for lu_impls.c:

Functions

int rb_dgetrf (int m, int n, double *A, int lda, int *ipiv)
 Computes the PLU factorization of an m by n matrix A, i.e. $ PA=LU $. More...
 
void rb_dscal (int n, double a, double *X, int incx)
 Scales a vector by a constant. $x\leftarrow ax$. More...
 
void rb_dswap (int n, double *X, int incx, double *Y, int incy)
 Swaps the value of vector X and Y. More...
 
void rb_daxpy (int n, double a, const double *X, int incx, double *Y, int incy)
 Scale a vector X by a constant add add it to another vector Y. $y\leftarrow y+ax$. More...
 
int rb_idamax (int n, double *X, int incx)
 Finds the index of the element in X which has the maximum absolute value. More...
 

Detailed Description

Simple implementations of PLU factorization.

Author
RyanBern

Function Documentation

void rb_daxpy ( int  n,
double  a,
const double *  X,
int  incx,
double *  Y,
int  incy 
)

Scale a vector X by a constant add add it to another vector Y. $y\leftarrow y+ax$.

Parameters
nThe length of X and Y.
aThe scaling constant.
XThe pointer to the storage of X.
incxThe increment of indices of X.
YInput/Output. The pointer to the storage of Y.
incyThe increment of indices of Y.
int rb_dgetrf ( int  m,
int  n,
double *  A,
int  lda,
int *  ipiv 
)

Computes the PLU factorization of an m by n matrix A, i.e. $ PA=LU $.

Parameters
mThe number of rows of A.
nThe number of columns of A.
AInput/Output. Pointer to the storage of A.
ldaThe leading dimension of A.
ipivOutput. The integer array that stores the pivoting indices. That is, row i exchanges with row ipiv[i].
Returns
The function returns 0 when it exits normally. When it returns with a positive integer i, it means that lu stops at i-th row because A may be singular or ill-conditioned.

On exit, R is stored at the upper triangular/trapezoidal part of A, L is stored at the strictly lower triangular/trapezoidal part of A, the diagonal of L is not stored.

For example, suppose A is 4 by 3

\[ A = \left(\begin{array}{ccc} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \\ a_{41} & a_{42} & a_{43} \\ \end{array}\right) \]

Then after LU is completed, A is overwritten by

\[ A = \left(\begin{array}{ccc} u_{11} & u_{12} & u_{13} \\ l_{21} & u_{22} & u_{23} \\ l_{31} & l_{32} & u_{33} \\ l_{41} & l_{42} & l_{43} \\ \end{array}\right) \]

void rb_dscal ( int  n,
double  a,
double *  X,
int  incx 
)

Scales a vector by a constant. $x\leftarrow ax$.

Parameters
nThe length of X.
aThe scaling factor.
XThe pointer to the storage of X.
incxThe increment of indices.
void rb_dswap ( int  n,
double *  X,
int  incx,
double *  Y,
int  incy 
)

Swaps the value of vector X and Y.

Parameters
nThe length of X and Y.
XThe pointer to the storage of X.
incxThe increment of indices of X.
YThe pointer to the storage of Y.
incyThe increment of indices of Y.
int rb_idamax ( int  n,
double *  X,
int  incx 
)

Finds the index of the element in X which has the maximum absolute value.

Parameters
nThe length of X.
XThe pointer to the storage of X.
incxThe increment of indices of X.