BlockIP
|
Class for manipulating matrices, and interfacing SparseChol. More...
#include <MatrixBlockIP.h>
Classes | |
struct | Order_ija |
Auxiliary struct for sorting matrices in ija format. More... | |
struct | Order_vector |
Auxiliary struct for sorting vectors. More... | |
Public Member Functions | |
MatrixBlockIP (int blocks=1) | |
Constructor. | |
MatrixBlockIP (MatrixBlockIP *mbip) | |
Copy constructor, does not copy SparseChol. | |
~MatrixBlockIP () | |
Destructor. | |
void | copy (MatrixBlockIP *mbip) |
Copy, does not copy SparseChol. | |
void | reset () |
Comes back to the initial state. | |
void | restore () |
Comes back to the state after create the matrix. | |
void | create_general_matrix_row_wise (int m, int n, int nz, int *&inirowa, int *&icola, double *&a) |
Native method to create a general row-wise packed matrix. | |
void | create_general_matrix_column_wise (int m, int n, int nz, int *&inicola, int *&irowa, double *&a) |
Native method to create a general column-wise packed matrix. | |
void | create_network_matrix (int num_arcs, int num_nodes, int *&src, int *&dst, bool oriented=true) |
Native method to create a network matrix. | |
void | create_identity_matrix (int dim) |
Native method to create a identity matrix of dimension dim. | |
void | create_idty_idty_matrix (int nrows) |
Native method to create a identity-identity matrix with two identities [I I]. | |
void | create_diagonal_matrix (int dim, double *&d) |
Native method to create a diagonal matrix D= diag(d) of dimension dim. | |
void | create_diag_diag_matrix (int nrows, double *&d1, double *&d2) |
Native method to create a diagonal-diagonal matrix D= [D1 D2]. | |
void | create_general_matrix_format_ija (int m, int n, int nz, int *&row_index, int *&col_index, double *&values) |
Creates a general matrix in format ija. | |
void | compute_full_matrix (int numBlocks, bool sameN, MatrixBlockIP N[], bool sameL, MatrixBlockIP L[], int numActiveLnk=0, int *listActiveLnk=NULL) |
Builds a packed rowwise format structured matrix based on diagonal blocks and linking constraints blocks. | |
void | analyze_D (int numBlocks, bool sameL, MatrixBlockIP L[]) |
void | analyze_D_diagonal (int numBlocks, bool sameL, MatrixBlockIP L[]) |
void | analyze_D_gen_sym_uptr (int numBlocks, bool sameL, MatrixBlockIP L[]) |
void | compute_D (int numBlocks, bool sameL, MatrixBlockIP L[], bool isActive[], int iniTheta[], double Theta[]) |
Compute D = Theta_(numBlocks+1) + sum{i..numBlocks} L_i*Theta_i*L_i'. | |
void | compute_D_diagonal (int numBlocks, bool sameL, MatrixBlockIP L[], bool isActive[], int iniTheta[], double Theta[]) |
Compute D = Theta_(numBlocks+1) + sum{i in 1..numBlocks} L_i*Theta_i*L_i' when D is diagonal. | |
void | compute_D_gen_sym_uptr (int numBlocks, bool sameL, MatrixBlockIP L[], bool isActive[], int iniTheta[], double Theta[]) |
Compute D = Theta_(numBlocks+1) + sum{i..numBlocks} L_i*Theta_i*L_i' when D is a symmetric general matrix. | |
void | native_to_general (bool delete_native_format=false) |
Calculates and stores the matrix in packed rowwise format. | |
void | ija_to_rowwise () |
Calculates and stores the matrix in packed rowwise format. | |
void | network_to_general () |
Calculates and stores the network matrix (either oriented or nonoriented) in packed rowwise format. | |
void | identity_to_general () |
Calculates and stores the I matrix in packed rowwise format. | |
void | diagonal_to_general () |
Calculates and stores the diagonal D matrix in packed rowwise format. | |
void | idty_idty_to_general () |
Calculates and stores the matrix [I I] in packed rowwise format. | |
void | diag_diag_to_general () |
Calculates and stores the matrix [D1 D2] in packed rowwise format. | |
void | network_to_ija_format () |
Calculates and stores the network matrix in ija format. It considers both oriented and nonoriented cases. | |
void | identity_to_ija_format () |
Calculates and stores the identity I matrix in ija format. | |
void | diagonal_to_ija_format () |
Calculates and stores the diagonal D1 matrix in ija format. | |
void | idty_idty_to_ija_format () |
Calculates and stores the matrix [I I] in ija format. | |
void | diag_diag_to_ija_format () |
Calculates and stores the matrix [D1 D2] in ija format. | |
void | order_matrix () |
Order the matrix when has been created in row-wise or column-wise format. | |
void | mul_Mv (double vout[], const double vin[]) |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (driver) | |
void | mul_Mtv (double vout[], const double vin[]) |
MatrixTranspose-vector product vout=M(t)*vin (vout(n),vin(m) (driver) | |
void | add_mul_Mv (double vout[], const double vin[]) |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (driver) | |
void | add_mul_Mtv (double vout[], const double vin[]) |
Add matrixTranspose-vector product vout += M(t)*vin (vout(n),vin(m) (driver) | |
void | exist_var_in_row (int column, bool appear[], double coefs[]) |
Given a column determines if exists an element for each row of the matrix, in case of exist returns the value. | |
void | add_new_column (int size, int irows[], double values[]) |
Add a new column into the matrix. | |
void | add_new_columns (int num_columns, int size[], int *irows[], double *values[]) |
Add new columns into the matrix. | |
void | change_columns_sign (int size, int columns[]) |
Changes the sign of some columns. | |
void | change_rows_sign (int size, int rows[]) |
Change the sign of some rows. | |
void | delete_rows (int size, int rows[]) |
Delete some rows. | |
int | get_column (int column, int *&irows, double *&values, bool invert_sign=false) |
Gets a column of the matrix. | |
void | symbolic_fact_MMt (CHOL_SOLVER chslv=SPRSBLKLLT, int *prov_pfa=NULL, int *prov_ipfa=NULL, NUMBERING prov_pfa_numbering=NOT_COMPUTED) |
Interface routine to SparseChol symbolic factorization. | |
void | numeric_fact_MMt (double *Theta, int i_k=0) |
Interface routine to SparseChol numeric factorization. | |
void | numeric_solve_MMt (double *rhs, int i_k=0, WHO_PERMUTES whoperm=CHOLESKY) |
Interface routine to SparseChol numeric solve. | |
void | symbolic_fact_M (CHOL_SOLVER chslv=SPRSBLKLLT, int *prov_pfa=NULL, int *prov_ipfa=NULL, NUMBERING prov_pfa_numbering=NOT_COMPUTED) |
Interface routine to SparseChol symbolic factorization. | |
void | numeric_fact_M () |
Interface routine to SparseChol numeric factorization. | |
void | numeric_solve_M (double *rhs, WHO_PERMUTES whoperm=CHOLESKY) |
Interface routine to SparseChol numeric solve. | |
int | get_pfa (int i) |
Interface routine to SparseChol get_pfa(). | |
int | get_ipfa (int i) |
Interface routine to SparseChol get_ipfa(). | |
int | get_maxlnz () |
Interface routine to SparseChol get_maxlnz(). | |
int | get_maxfillin () |
Interface routine to SparseChol get_maxfillin(). | |
int | get_njka () |
Interface routine to SparseChol get_njka(). | |
int | get_num_zero_pivots () |
Interface routine to SparseChol get_num_zero_pivots(). | |
int | get_num_semidef_matrix () |
Interface routine to SparseChol get_semidef_matrix(). | |
void | print_matrix (bool ija=true, bool start_one=true) |
Print the matrix. | |
void | print_matrix (ofstream &outfile, bool print_ija=true, bool start_one=true) |
Write the matrix into a file. | |
void | print_vector (double *v, int size, string name) |
Print some positions and name of a vector. | |
void | column_wise_to_row_wise_format () |
Convert a matrix in column-wise format to row-wise format. | |
void | row_wise_to_column_wise_format () |
Convert a matrix in column-wise format to row-wise format. | |
Public Attributes | |
TYPE_MATRIX | type |
Type of matrix. | |
int | m |
Number of rows. | |
int | n |
Number of columns. | |
bool | ija |
True if irowa, icola and a are stored. | |
bool | rowwise |
True if inirowa, icola and a are stored. | |
bool | columnwise |
True if the matrix is stored in column-wise packed format, incompatible with rowwise. | |
int | nz |
Number of non-zero elements. | |
double * | a |
Value of non-zero elements. | |
int * | inirowa |
Index to the first element of each row. | |
int * | icola |
Column position for each element. | |
int * | inicola |
Index to the first element of each column. | |
int * | irowa |
Row position for each element. | |
TYPE_ORIENTATION | type_orientation |
Type of orientation, by default, oriented. | |
int | num_arcs |
Number of arcs. | |
int | num_nodes |
Number of nodes. | |
int * | src |
Source of each arc. | |
int * | dst |
Destination of each arc. | |
double * | d1 |
d1 for DIAGONAL and 1st submatrix of DIAG_DIAG | |
double * | d2 |
d2 for 2nd submatrix of DIAG_DIAG | |
SparseChol | chol |
Sparse Cholesky class. | |
int | sizeL |
int * | inirowLLt |
int * | icolLLt |
int * | blockD |
int * | inivalD |
int * | icolD |
double * | valD |
bool | made_symbfct_MMt |
bool | made_symbfct_M |
bool | made_analyze_D |
int | num_blocks |
Private Member Functions | |
void | free_memory () |
Free all the memory allocated by the application - not the user. | |
void | mul_Mv_row_wise (double vout[], const double vin[]) |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (general rowwise matrix) | |
void | mul_Mtv_row_wise (double vout[], const double vin[]) |
MatrixTranspose-vector product vout=M(t)*vin (vout(n),vin(m) (general rowwise matrix) | |
void | add_mul_Mv_row_wise (double vout[], const double vin[]) |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (general rowwise matrix) | |
void | add_mul_Mtv_row_wise (double vout[], const double vin[]) |
Add matrixTranspose-vector product vout += M(t)*vin (vout(n),vin(m) (general rowwise matrix) | |
void | mul_Mv_column_wise (double vout[], const double vin[]) |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (general columnwise matrix) | |
void | mul_Mtv_column_wise (double vout[], const double vin[]) |
MatrixTranspose-vector product vout=M(t)*vin (vout(n),vin(m) (general columnwise matrix) | |
void | add_mul_Mv_column_wise (double vout[], const double vin[]) |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (general columnwise matrix) | |
void | add_mul_Mtv_column_wise (double vout[], const double vin[]) |
Add matrixTranspose-vector product vout += M(t)*vin (vout(n),vin(m) (general columnwise matrix) | |
void | mul_Mv_network (double vout[], const double vin[]) |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (network matrix, either oriented or nonoriented) | |
void | mul_Mtv_network (double vout[], const double vin[]) |
MatrixTranspose-vector product vout=M(t)*vin (vout(n),vin(m) (network matrix, either oriented or nonoriented) | |
void | add_mul_Mv_network (double vout[], const double vin[]) |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (network matrix, either oriented or nonoriented) | |
void | add_mul_Mtv_network (double vout[], const double vin[]) |
Add matrixTranspose-vector product vout += M(t)*vin (vout(n),vin(m) (network matrix, either oriented or nonoriented) | |
void | mul_Mv_identity (double vout[], const double vin[]) |
Identity-vector product vout=M*vin (vout(m),vin(n)) | |
void | add_mul_Mv_identity (double vout[], const double vin[]) |
Add Identity-vector product vout += M*vin (vout(m),vin(n)) | |
void | mul_Mv_diagonal (double vout[], const double vin[]) |
Diagonal-vector product vout=D*vin (vout(m),vin(n)) D is diagonal, m=n. | |
void | add_mul_Mv_diagonal (double vout[], const double vin[]) |
Add Diagonal-vector product vout += D*vin (vout(m),vin(n)) D is diagonal, m=n. | |
void | mul_Mv_idty_idty (double vout[], const double vin[]) |
Matrix-vector product vout= [I I]*vin (vout(m),vin(n)) (M= [I I] matrix, n= 2*m) | |
void | mul_Mtv_idty_idty (double vout[], const double vin[]) |
MatrixTranspose-vector product vout= [I I]'*vin (vout(n),vin(m) (M= [I I] matrix, n= 2*m) | |
void | add_mul_Mv_idty_idty (double vout[], const double vin[]) |
Add matrix-vector product vout += [I I]*vin (vout(m),vin(n)) (M= [I I] matrix, n= 2*m) | |
void | add_mul_Mtv_idty_idty (double vout[], const double vin[]) |
Add matrixTranspose-vector product vout += [I I]'*vin (vout(n),vin(m) (M= [I I] matrix, n= 2*m) | |
void | mul_Mv_diag_diag (double vout[], const double vin[]) |
Matrix-vector product vout= [D1 D2]*vin (vout(m),vin(n)) (M= [D1 D2] matrix, n= 2*m) | |
void | mul_Mtv_diag_diag (double vout[], const double vin[]) |
MatrixTranspose-vector product vout= [D1 D2]'*vin (vout(n),vin(m) (M= [D1 D2] matrix, n= 2*m) | |
void | add_mul_Mv_diag_diag (double vout[], const double vin[]) |
Add matrix-vector product vout += [D1 D2]*vin (vout(m),vin(n)) (M= [D1 D2] matrix, n= 2*m) | |
void | add_mul_Mtv_diag_diag (double vout[], const double vin[]) |
Add matrixTranspose-vector product vout += [D1 D2]'*vin (vout(n),vin(m) (M= [D1 D2] matrix, n= 2*m) | |
void | mul_Mv_gen_sym_uptr (double vout[], const double vin[]) |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (general symmetric upper triangular rowwise matrix) | |
void | add_mul_Mv_gen_sym_uptr (double vout[], const double vin[]) |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (general symmetric upper triangular rowwise matrix) | |
void | order_packed_format (int begsize, int nz, int *&beg, int *&ind, double *&val) |
Order a matrix packed format (both column-wise and row-wise) | |
Class for manipulating matrices, and interfacing SparseChol.
MatrixBlockIP::MatrixBlockIP | ( | int | blocks = 1 | ) |
Constructor.
blocks | number of blocks where this matrix will appear; |
MatrixBlockIP::MatrixBlockIP | ( | MatrixBlockIP * | mbip | ) |
Copy constructor, does not copy SparseChol.
mbip | MatrixBlockIP to copy |
MatrixBlockIP::~MatrixBlockIP | ( | ) |
Destructor.
void MatrixBlockIP::add_mul_Mtv | ( | double | vout[], |
const double | vin[] | ||
) |
Add matrixTranspose-vector product vout += M(t)*vin (vout(n),vin(m) (driver)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrixTranspose-vector product vout += M(t)*vin (vout(n),vin(m) (general columnwise matrix)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrixTranspose-vector product vout += [D1 D2]'*vin (vout(n),vin(m) (M= [D1 D2] matrix, n= 2*m)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrixTranspose-vector product vout += [I I]'*vin (vout(n),vin(m) (M= [I I] matrix, n= 2*m)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrixTranspose-vector product vout += M(t)*vin (vout(n),vin(m) (network matrix, either oriented or nonoriented)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrixTranspose-vector product vout += M(t)*vin (vout(n),vin(m) (general rowwise matrix)
vout | Result of the product |
vin | Vector to product |
void MatrixBlockIP::add_mul_Mv | ( | double | vout[], |
const double | vin[] | ||
) |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (driver)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (general columnwise matrix)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrix-vector product vout += [D1 D2]*vin (vout(m),vin(n)) (M= [D1 D2] matrix, n= 2*m)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add Diagonal-vector product vout += D*vin (vout(m),vin(n)) D is diagonal, m=n.
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (general symmetric upper triangular rowwise matrix)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
Add Identity-vector product vout += M*vin (vout(m),vin(n))
Identity matrix, m=n, just add input to output vector
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrix-vector product vout += [I I]*vin (vout(m),vin(n)) (M= [I I] matrix, n= 2*m)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (network matrix, either oriented or nonoriented)
vout | Result of the product |
vin | Vector to product |
|
inlineprivate |
Add matrix-vector product vout += M*vin (vout(m),vin(n)) (general rowwise matrix)
vout | Result of the product |
vin | Vector to product |
void MatrixBlockIP::add_new_column | ( | int | size, |
int | irows[], | ||
double | values[] | ||
) |
Add a new column into the matrix.
size | Number of non-zero elements of the new column |
irows | Row position for each element, have to be ordered |
values | Value of non-zero elements |
void MatrixBlockIP::add_new_columns | ( | int | num_columns, |
int | size[], | ||
int * | irows[], | ||
double * | values[] | ||
) |
Add new columns into the matrix.
num_columns | Number of columns to add |
size | number of non-zero elements of the new column for each column |
irows | Row position for each element and column, have to be ordered |
values | Value of non-zero elements for each column |
|
inline |
Create internal structure arrays to compute D = Theta_(numBlocks+1) + sum{i..numBlocks} L_i*Theta_i*L_i' It decides whether D is DIAGONAL or GEN_SYM_UPTR
numBlocks | Number of diagonal blocks |
sameL | Define if the same matrix is used for each L block |
L | Linking constraints blocks |
void MatrixBlockIP::analyze_D_diagonal | ( | int | numBlocks, |
bool | sameL, | ||
MatrixBlockIP | L[] | ||
) |
Create internal structure arrays to compute D = Theta_(numBlocks+1) + sum{1..numBlocks} L_i*Theta_i*L_i' when D is a diagonal
numBlocks | Number of diagonal blocks |
sameL | Define if the same matrix is used for each L block |
L | Linking constraints blocks |
void MatrixBlockIP::analyze_D_gen_sym_uptr | ( | int | numBlocks, |
bool | sameL, | ||
MatrixBlockIP | L[] | ||
) |
Create internal structure arrays to compute D = Theta_(numBlocks+1) + sum{i..numBlocks} L_i*Theta_i*L_i' when D is a general symmetric upper triangular matrix
numBlocks | Number of diagonal blocks |
sameL | Define if the same matrix is used for each L block |
L | Linking constraints blocks |
void MatrixBlockIP::change_columns_sign | ( | int | size, |
int | columns[] | ||
) |
Changes the sign of some columns.
size | Number of columns to change the sign |
columns | Index to the columns to change the sign |
void MatrixBlockIP::change_rows_sign | ( | int | size, |
int | rows[] | ||
) |
Change the sign of some rows.
size | Number of rows to change the sign |
rows | Index to the rows to change the sign |
void MatrixBlockIP::column_wise_to_row_wise_format | ( | ) |
Convert a matrix in column-wise format to row-wise format.
|
inline |
Compute D = Theta_(numBlocks+1) + sum{i..numBlocks} L_i*Theta_i*L_i'.
numBlocks | Number of diagonal blocks |
sameL | Define if the same matrix is used for each L block |
isActive | Says what linking constrains are active |
iniTheta | Indice to the first element of the Theta matrix of each block |
Theta | numBlocks diagonal matrices with dimension n_i x n_i |
void MatrixBlockIP::compute_D_diagonal | ( | int | numBlocks, |
bool | sameL, | ||
MatrixBlockIP | L[], | ||
bool | isActive[], | ||
int | iniTheta[], | ||
double | Theta[] | ||
) |
Compute D = Theta_(numBlocks+1) + sum{i in 1..numBlocks} L_i*Theta_i*L_i' when D is diagonal.
numBlocks | Number of diagonal blocks |
sameL | Define if the same matrix is used for each L block |
isActive | Says what linking constrains are active |
iniTheta | Indice to the first element of the Theta matrix of each block |
Theta | numBlocks diagonal matrices with dimension n_i x n_i |
void MatrixBlockIP::compute_D_gen_sym_uptr | ( | int | numBlocks, |
bool | sameL, | ||
MatrixBlockIP | L[], | ||
bool | isActive[], | ||
int | iniTheta[], | ||
double | Theta[] | ||
) |
Compute D = Theta_(numBlocks+1) + sum{i..numBlocks} L_i*Theta_i*L_i' when D is a symmetric general matrix.
numBlocks | Number of diagonal blocks |
sameL | Define if the same matrix is used for each L block |
isActive | Says what linking constrains are active |
iniTheta | Indice to the first element of the Theta matrix of each block |
Theta | numBlocks diagonal matrices with dimension n_i x n_i |
void MatrixBlockIP::compute_full_matrix | ( | int | numBlocks, |
bool | sameN, | ||
MatrixBlockIP | N[], | ||
bool | sameL, | ||
MatrixBlockIP | L[], | ||
int | numActiveLnk = 0 , |
||
int * | listActiveLnk = NULL |
||
) |
Builds a packed rowwise format structured matrix based on diagonal blocks and linking constraints blocks.
numBlocks | Number of diagonal blocks |
sameN | Define if the same matrix is used for each N block |
N | Diagonal blocks |
sameL | Define if the same matrix is used for each L block |
L | Linking constraints blocks |
numActiveLnk | Number of active lnk |
listActiveLnk | List of active linking, j=listActiveLnk[i], i=1..numActiveLnk, j in {1,..,l_link}) If listActiveLnk is NULL all L rows are used |
void MatrixBlockIP::copy | ( | MatrixBlockIP * | mbip | ) |
Copy, does not copy SparseChol.
mbip | MatrixBlockIP to copy |
void MatrixBlockIP::create_diag_diag_matrix | ( | int | nrows, |
double *& | d1, | ||
double *& | d2 | ||
) |
Native method to create a diagonal-diagonal matrix D= [D1 D2].
where D1= diag(d1), D2= diag(d2) (dimension: nrows x (2nrows))
nrows | Number of rows |
d1 | Values of the diagonal D1 |
d2 | Values of the diagonal D2 |
void MatrixBlockIP::create_diagonal_matrix | ( | int | dim, |
double *& | d | ||
) |
Native method to create a diagonal matrix D= diag(d) of dimension dim.
dim | Dimension of the matrix |
d | Values of the diagonal elements |
void MatrixBlockIP::create_general_matrix_column_wise | ( | int | m, |
int | n, | ||
int | nz, | ||
int *& | inicola, | ||
int *& | irowa, | ||
double *& | a | ||
) |
Native method to create a general column-wise packed matrix.
m | Number of rows |
n | Number of columns |
nz | Number of non-zero elements |
inicola | Index to the first element of each column |
irowa | Row position for each element |
a | Value of non-zero elements |
void MatrixBlockIP::create_general_matrix_format_ija | ( | int | m, |
int | n, | ||
int | nz, | ||
int *& | row_index, | ||
int *& | col_index, | ||
double *& | values | ||
) |
Creates a general matrix in format ija.
m | Number of rows |
n | Number of columns |
nz | Number of non-zero elements |
row_index | Row position for each element |
col_index | Column position for each element |
values | Value of non-zero elements |
void MatrixBlockIP::create_general_matrix_row_wise | ( | int | m, |
int | n, | ||
int | nz, | ||
int *& | inirowa, | ||
int *& | icola, | ||
double *& | a | ||
) |
Native method to create a general row-wise packed matrix.
m | Number of rows |
n | Number of columns |
nz | Number of non-zero elements |
inirowa | Index to the first element of each row |
icola | Column position for each element |
a | Value of non-zero elements |
void MatrixBlockIP::create_identity_matrix | ( | int | dim | ) |
Native method to create a identity matrix of dimension dim.
dim | Dimension of the matrix |
void MatrixBlockIP::create_idty_idty_matrix | ( | int | nrows | ) |
Native method to create a identity-identity matrix with two identities [I I].
Dimension: nrows x (2nrows)
nrows | Number of rows |
void MatrixBlockIP::create_network_matrix | ( | int | num_arcs, |
int | num_nodes, | ||
int *& | src, | ||
int *& | dst, | ||
bool | oriented = true |
||
) |
Native method to create a network matrix.
num_arcs | Number of arcs |
num_nodes | Number of nodes |
src | Source of each arc. Dimension num_arcs |
dst | Destination of each arc. Dimension num_arcs |
oriented | For oriented/nonoriented networks |
void MatrixBlockIP::delete_rows | ( | int | size, |
int | rows[] | ||
) |
Delete some rows.
size | Number of rows to be deleted |
rows | Index to the rows to be deleted, must be ordered |
|
inline |
Calculates and stores the matrix [D1 D2] in packed rowwise format.
void MatrixBlockIP::diag_diag_to_ija_format | ( | ) |
Calculates and stores the matrix [D1 D2] in ija format.
|
inline |
Calculates and stores the diagonal D matrix in packed rowwise format.
void MatrixBlockIP::diagonal_to_ija_format | ( | ) |
Calculates and stores the diagonal D1 matrix in ija format.
void MatrixBlockIP::exist_var_in_row | ( | int | column, |
bool | appear[], | ||
double | coefs[] | ||
) |
Given a column determines if exists an element for each row of the matrix, in case of exist returns the value.
column | The column to examine |
appear | The array that says if a element exists or not for each row. The user must allocate the space before call the function |
coefs | The array that have the value of the element if exists, if not the content in that position is indeterminate. The user must allocate the space before call the function |
|
private |
Free all the memory allocated by the application - not the user.
int MatrixBlockIP::get_column | ( | int | column, |
int *& | irows, | ||
double *& | values, | ||
bool | invert_sign = false |
||
) |
Gets a column of the matrix.
column | Index to the column |
irows | Row index for each ealement. Must be freed with delete[] |
values | Value for each non-zero element. Must be freed with delete[] |
invert_sign | If true change the sign of each element in the column |
|
inline |
Interface routine to SparseChol get_ipfa().
|
inline |
Interface routine to SparseChol get_maxfillin().
|
inline |
Interface routine to SparseChol get_maxlnz().
|
inline |
Interface routine to SparseChol get_njka().
|
inline |
Interface routine to SparseChol get_semidef_matrix().
|
inline |
Interface routine to SparseChol get_num_zero_pivots().
|
inline |
Interface routine to SparseChol get_pfa().
|
inline |
Calculates and stores the I matrix in packed rowwise format.
void MatrixBlockIP::identity_to_ija_format | ( | ) |
Calculates and stores the identity I matrix in ija format.
|
inline |
Calculates and stores the matrix [I I] in packed rowwise format.
void MatrixBlockIP::idty_idty_to_ija_format | ( | ) |
Calculates and stores the matrix [I I] in ija format.
void MatrixBlockIP::ija_to_rowwise | ( | ) |
Calculates and stores the matrix in packed rowwise format.
void MatrixBlockIP::mul_Mtv | ( | double | vout[], |
const double | vin[] | ||
) |
MatrixTranspose-vector product vout=M(t)*vin (vout(n),vin(m) (driver)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
MatrixTranspose-vector product vout=M(t)*vin (vout(n),vin(m) (general columnwise matrix)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
MatrixTranspose-vector product vout= [D1 D2]'*vin (vout(n),vin(m) (M= [D1 D2] matrix, n= 2*m)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
MatrixTranspose-vector product vout= [I I]'*vin (vout(n),vin(m) (M= [I I] matrix, n= 2*m)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
MatrixTranspose-vector product vout=M(t)*vin (vout(n),vin(m) (network matrix, either oriented or nonoriented)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
MatrixTranspose-vector product vout=M(t)*vin (vout(n),vin(m) (general rowwise matrix)
vout | Result of the product. Must be allocated |
vin | Vector to product |
void MatrixBlockIP::mul_Mv | ( | double | vout[], |
const double | vin[] | ||
) |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (driver)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (general columnwise matrix)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
Matrix-vector product vout= [D1 D2]*vin (vout(m),vin(n)) (M= [D1 D2] matrix, n= 2*m)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
Diagonal-vector product vout=D*vin (vout(m),vin(n)) D is diagonal, m=n.
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (general symmetric upper triangular rowwise matrix)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
Identity-vector product vout=M*vin (vout(m),vin(n))
Identity matrix, m=n, just copy input to output vector
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
Matrix-vector product vout= [I I]*vin (vout(m),vin(n)) (M= [I I] matrix, n= 2*m)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (network matrix, either oriented or nonoriented)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inlineprivate |
Matrix-vector product vout=M*vin (vout(m),vin(n)) (general rowwise matrix)
vout | Result of the product. Must be allocated |
vin | Vector to product |
|
inline |
Calculates and stores the matrix in packed rowwise format.
delete_native_format | If true only packed rowwise format will be stored |
void MatrixBlockIP::network_to_general | ( | ) |
Calculates and stores the network matrix (either oriented or nonoriented) in packed rowwise format.
void MatrixBlockIP::network_to_ija_format | ( | ) |
Calculates and stores the network matrix in ija format. It considers both oriented and nonoriented cases.
|
inline |
Interface routine to SparseChol numeric factorization.
|
inline |
Interface routine to SparseChol numeric factorization.
|
inline |
Interface routine to SparseChol numeric solve.
|
inline |
Interface routine to SparseChol numeric solve.
void MatrixBlockIP::order_matrix | ( | ) |
Order the matrix when has been created in row-wise or column-wise format.
|
private |
Order a matrix packed format (both column-wise and row-wise)
begsize | Number of rows (if row-wise) or columns (if column-wise) + 1 |
nz | Number of nonzeros in the matrix. |
beg | Rows (if row-wise) or columns (if column-wise) starts of the matrix. |
ind | Columns (if row-wise) or rows (if column-wise) indices of nonzeros entries. |
val | Values of the nonzero entries. |
void MatrixBlockIP::print_matrix | ( | bool | print_ija = true , |
bool | start_one = true |
||
) |
Print the matrix.
print_ija | If print_ija is true then write triple (i,j,a) whenever possible (if matrix is in ija or packed rowwise format); if print_ija=false then writes (inirow, j, a) whenever possible (if matrix is in packed rowwise format). |
start_one | Start vectors at position 1 (true) or zero (false) |
void MatrixBlockIP::print_matrix | ( | ofstream & | outfile, |
bool | print_ija = true , |
||
bool | start_one = true |
||
) |
Write the matrix into a file.
outfile | Output file stream where the matrix will be printed |
void MatrixBlockIP::print_vector | ( | double * | v, |
int | size, | ||
string | name | ||
) |
Print some positions and name of a vector.
v | Vector to print |
size | Number of positions to print |
name | Vector name |
void MatrixBlockIP::reset | ( | ) |
Comes back to the initial state.
void MatrixBlockIP::restore | ( | ) |
Comes back to the state after create the matrix.
void MatrixBlockIP::row_wise_to_column_wise_format | ( | ) |
Convert a matrix in column-wise format to row-wise format.
|
inline |
Interface routine to SparseChol symbolic factorization.
|
inline |
Interface routine to SparseChol symbolic factorization.
double* MatrixBlockIP::a |
Value of non-zero elements.
int* MatrixBlockIP::blockD |
SparseChol MatrixBlockIP::chol |
Sparse Cholesky class.
For sparse Cholesky
bool MatrixBlockIP::columnwise |
True if the matrix is stored in column-wise packed format, incompatible with rowwise.
double* MatrixBlockIP::d1 |
d1 for DIAGONAL and 1st submatrix of DIAG_DIAG
Diagonal format attributes
double* MatrixBlockIP::d2 |
d2 for 2nd submatrix of DIAG_DIAG
int* MatrixBlockIP::dst |
Destination of each arc.
int* MatrixBlockIP::icola |
Column position for each element.
int* MatrixBlockIP::icolD |
int* MatrixBlockIP::icolLLt |
bool MatrixBlockIP::ija |
True if irowa, icola and a are stored.
int* MatrixBlockIP::inicola |
Index to the first element of each column.
General column-wise packed format attributes
int* MatrixBlockIP::inirowa |
Index to the first element of each row.
General row-wise packed format attributes
int* MatrixBlockIP::inirowLLt |
int* MatrixBlockIP::inivalD |
int* MatrixBlockIP::irowa |
Row position for each element.
int MatrixBlockIP::m |
Number of rows.
bool MatrixBlockIP::made_analyze_D |
boolean to check whether analyze_D already made, needed to compute_D()
bool MatrixBlockIP::made_symbfct_M |
bool MatrixBlockIP::made_symbfct_MMt |
boolean to check whether symbolic factorization already made
int MatrixBlockIP::n |
Number of columns.
int MatrixBlockIP::num_arcs |
Number of arcs.
int MatrixBlockIP::num_blocks |
number of replications of this matrix; this is needed to store space for num_blocks numerical factorization of M*Theta[i]*M', for different Theta[i], i=0,...,num_blocks-1 This value is set by the minimization algorithm, which needs the factorizations.
int MatrixBlockIP::num_nodes |
Number of nodes.
int MatrixBlockIP::nz |
Number of non-zero elements.
Common packed format attributes
bool MatrixBlockIP::rowwise |
True if inirowa, icola and a are stored.
int MatrixBlockIP::sizeL |
For D Matrix
int* MatrixBlockIP::src |
Source of each arc.
TYPE_MATRIX MatrixBlockIP::type |
Type of matrix.
Common in all types matrix
TYPE_ORIENTATION MatrixBlockIP::type_orientation |
Type of orientation, by default, oriented.
Network format attributes
double* MatrixBlockIP::valD |