/** Deallocate a matrix. * * \ingroup allocate_group_C * * \param A The matrix. */ void bml_deallocate( bml_matrix_t ** A) { if (A == NULL) { LOG_DEBUG("A is NULL\n"); } else if (*A == NULL) { LOG_DEBUG("*A is NULL\n"); } else { switch (bml_get_type(*A)) { case dense: bml_deallocate_dense(*A); break; case ellpack: bml_deallocate_ellpack(*A); break; default: LOG_ERROR("unknown matrix type (%d)\n", bml_get_type(*A)); break; } *A = NULL; } }
/** Copy a matrix. * * \param A Matrix to copy * \param B Copy of Matrix A */ void bml_copy( const bml_matrix_t * A, bml_matrix_t * B) { assert(A != NULL); assert(B != NULL); LOG_DEBUG("copying matrix\n"); if (bml_get_type(A) != bml_get_type(B)) { LOG_ERROR("type mismatch\n"); } if (bml_get_N(A) != bml_get_N(B)) { LOG_ERROR("matrix size mismatch\n"); } if (bml_get_M(A) != bml_get_M(B)) { LOG_ERROR("matrix parameter mismatch\n"); } switch (bml_get_type(A)) { case dense: bml_copy_dense(A, B); break; case ellpack: bml_copy_ellpack(A, B); break; default: LOG_ERROR("unknown matrix type\n"); break; } }
void bml_set_row( bml_matrix_t * A, const int i, const void *row) { switch (bml_get_type(A)) { case dense: bml_set_row_dense(A, i, row); break; default: LOG_ERROR("unknown matrix type\n"); break; } }
/** Transpose matrix. * * \ingroup transpose_group_C * * \param A Matrix to be transposed * \return Transposed A */ void bml_transpose( bml_matrix_t * A) { switch (bml_get_type(A)) { case dense: bml_transpose_dense(A); break; case ellpack: bml_transpose_ellpack(A); break; default: LOG_ERROR("unknown matrix type\n"); break; } }
/** Threshold matrix. * * \ingroup threshold_group_C * * \param A Matrix to be thresholded * \param threshold Threshold value * \return Thresholded A */ void bml_threshold( bml_matrix_t * A, const double threshold) { switch (bml_get_type(A)) { case dense: bml_threshold_dense(A, threshold); break; case ellpack: bml_threshold_ellpack(A, threshold); break; default: LOG_ERROR("unknown matrix type\n"); break; } }
/** Calculate Gershgorin bounds. * * \ingroup normalize_group_C * * \param A Matrix to scale * returns maxeval Calculated max value * returns maxminusmin Calculated max-min value */ void * bml_gershgorin( const bml_matrix_t * A) { switch (bml_get_type(A)) { case dense: return bml_gershgorin_dense(A); break; case ellpack: return bml_gershgorin_ellpack(A); break; default: LOG_ERROR("unknown matrix type\n"); break; } return NULL; }
/** Transpose matrix. * * \ingroup transpose_group_C * * \param A Matrix to be transposed * \return Transposed A */ bml_matrix_t * bml_transpose_new( const bml_matrix_t * A) { switch (bml_get_type(A)) { case dense: return bml_transpose_new_dense(A); break; case ellpack: return bml_transpose_new_ellpack(A); break; default: LOG_ERROR("unknown matrix type\n"); break; } return NULL; }
void bml_diagonalize( const bml_matrix_t * A, double *eigenvalues, bml_matrix_t * eigenvectors) { switch (bml_get_type(A)) { case dense: bml_diagonalize_dense(A, eigenvalues, eigenvectors); break; case ellpack: LOG_ERROR("FIXME\n"); break; default: LOG_ERROR("unknown matrix type\n"); break; } }
/** Threshold matrix. * * \ingroup threshold_group_C * * \param A Matrix to be thresholded * \param threshold Threshold value * \return Thresholded A */ bml_matrix_t * bml_threshold_new( const bml_matrix_t * A, const double threshold) { switch (bml_get_type(A)) { case dense: return bml_threshold_new_dense(A, threshold); break; case ellpack: return bml_threshold_new_ellpack(A, threshold); break; default: LOG_ERROR("unknown matrix type\n"); break; } return NULL; }
/** Normalize matrix given Gershgorin bounds. * ** \ingroup normalize_group_C * * \param A Matrix to scale * \param maxeval Calculated max value * \param maxminusmin Calculated max-min value */ void bml_normalize( bml_matrix_t * A, const double maxeval, const double maxminusmin) { switch (bml_get_type(A)) { case dense: bml_normalize_dense(A, maxeval, maxminusmin); break; case ellpack: bml_normalize_ellpack(A, maxeval, maxminusmin); break; default: LOG_ERROR("unknown matrix type\n"); break; } }
/** Copy a matrix - result is a new matrix. * * \ingroup copy_group_C * * \param A Matrix to copy * \return A Copy of A */ bml_matrix_t * bml_copy_new( const bml_matrix_t * A) { bml_matrix_t *B = NULL; switch (bml_get_type(A)) { case dense: B = bml_copy_dense_new(A); break; case ellpack: B = bml_copy_ellpack_new(A); break; default: LOG_ERROR("unknown matrix type\n"); break; } return B; }