44
* Create and return a new, dense matrix. Elements of the matrix A
45
* may be accessed as A[i][j]
47
* @param nrows the number of rows for the new matrix.
48
* @param ncols the number of columns for the new matrix.
45
51
double ** Nlm_DenseMatrixNew(int nrows, int ncols);
55
* Create and return a new, dense, lower-triangular matrix. Elements
56
* of the matrix A may be accessed as A[i][j] for i <= j.
58
* @param n the dimension of the matrix.
48
61
double ** Nlm_LtriangMatrixNew(int n);
65
* Free a matrix created by Nlm_DenseMatrixNew or
66
* Nlm_LtriangMatrixNew.
68
* @param mat the matrix to be freed
51
72
void Nlm_DenseMatrixFree(double *** mat);
76
* Create and return a new Int4 matrix. Elements of the matrix A
77
* may be accessed as A[i][j]
79
* @param nrows the number of rows for the new matrix.
80
* @param ncols the number of columns for the new matrix.
54
83
Int4 ** Nlm_Int4MatrixNew(int nrows, int ncols);
87
* Free a matrix created by Nlm_DenseMatrixNew or
88
* Nlm_LtriangMatrixNew.
90
* @param mat the matrix to be freed
57
94
void Nlm_Int4MatrixFree(Int4 *** mat);
98
* Accessing only the lower triangular elements of the symmetric,
99
* positive definite matrix A, compute a lower triangular matrix L
100
* such that A = L L^T (Cholesky factorization.) Overwrite the lower
101
* triangle of A with L.
103
* This routine may be used with the Nlm_SolveLtriangPosDef routine to
104
* solve systems of equations.
106
* @param A the lower triangle of a symmetric, positive-definite
108
* @param n the size of A
59
110
NCBI_XBLAST_EXPORT
60
111
void Nlm_FactorLtriangPosDef(double ** A, int n);
115
* Solve the linear system \f$ L L^T y = b \f$, where L is a non-singular
116
* lower triangular matrix, usually computed using
117
* the Nlm_FactorLtriangPosDef routine.
119
* @param x on entry, the right hand size of the linear system
120
* L L^T y = b; on exit the solution
121
* @param n the size of x
122
* @param L a non-singular lower triangular matrix
62
124
NCBI_XBLAST_EXPORT
63
125
void Nlm_SolveLtriangPosDef(double x[], int n, double ** L);
129
* Compute the Euclidean norm (2-norm) of a vector.
131
* This routine is based on the (freely available) BLAS routine dnrm2,
132
* which handles the scale of the elements of v in a stable fashion.
135
* @param n the length of v
65
137
NCBI_XBLAST_EXPORT
66
138
double Nlm_EuclideanNorm(const double v[], int n);
142
* Let y = y + alpha * x
145
* @param x another vector
146
* @param n the length of x and y
147
* @param alpha a scale factor
68
149
NCBI_XBLAST_EXPORT
69
150
void Nlm_AddVectors(double y[], int n, double alpha,
70
151
const double x[]);
155
* Given a nonnegative vector x and a nonnegative scalar max, returns
156
* the largest value in [0, max] for which x + alpha * step_x >= 0.
158
* @param x a vector with nonnegative elements
159
* @param step_x another vector
160
* @param n the size of x and step_x
161
* @param max a nonnegative scalar
72
163
NCBI_XBLAST_EXPORT
73
164
double Nlm_StepBound(const double x[], int n,
74
165
const double step_x[], double max);