Various minor doc and comment fixes

This commit is contained in:
Andreas Longva 2021-01-25 17:12:46 +01:00
parent ccf1f18991
commit 5d5ed5be0b
6 changed files with 16 additions and 11 deletions

View File

@ -197,7 +197,6 @@ impl<T> CsMatrix<T> {
} }
impl<T: Scalar + One> CsMatrix<T> { impl<T: Scalar + One> CsMatrix<T> {
/// TODO
#[inline] #[inline]
pub fn identity(n: usize) -> Self { pub fn identity(n: usize) -> Self {
let offsets: Vec<_> = (0 ..= n).collect(); let offsets: Vec<_> = (0 ..= n).collect();

View File

@ -491,7 +491,7 @@ impl<T> CscMatrix<T>
} }
impl<T: Scalar + One> CscMatrix<T> { impl<T: Scalar + One> CscMatrix<T> {
/// TODO /// Constructs a CSC representation of the (square) `n x n` identity matrix.
#[inline] #[inline]
pub fn identity(n: usize) -> Self { pub fn identity(n: usize) -> Self {
Self { Self {

View File

@ -491,7 +491,7 @@ where
} }
impl<T: Scalar + One> CsrMatrix<T> { impl<T: Scalar + One> CsrMatrix<T> {
/// TODO /// Constructs a CSR representation of the (square) `n x n` identity matrix.
#[inline] #[inline]
pub fn identity(n: usize) -> Self { pub fn identity(n: usize) -> Self {
Self { Self {

View File

@ -140,8 +140,6 @@ impl<T: RealField> CscCholesky<T> {
/// # Panics /// # Panics
/// ///
/// Panics if the matrix is not square. /// Panics if the matrix is not square.
///
/// TODO: Take matrix by value or not?
pub fn factor(matrix: &CscMatrix<T>) -> Result<Self, CholeskyError> { pub fn factor(matrix: &CscMatrix<T>) -> Result<Self, CholeskyError> {
let symbolic = CscSymbolicCholesky::factor(matrix.pattern().clone()); let symbolic = CscSymbolicCholesky::factor(matrix.pattern().clone());
Self::factor_numerical(symbolic, matrix.values()) Self::factor_numerical(symbolic, matrix.values())

View File

@ -8,10 +8,13 @@ use std::iter;
/// The patterns are assumed to have the same major and minor dimensions. In other words, /// The patterns are assumed to have the same major and minor dimensions. In other words,
/// both patterns `A` and `B` must both stem from the same kind of compressed matrix: /// both patterns `A` and `B` must both stem from the same kind of compressed matrix:
/// CSR or CSC. /// CSR or CSC.
///
/// # Panics
///
/// Panics if the patterns don't have the same major and minor dimensions.
pub fn spadd_pattern(a: &SparsityPattern, pub fn spadd_pattern(a: &SparsityPattern,
b: &SparsityPattern) -> SparsityPattern b: &SparsityPattern) -> SparsityPattern
{ {
// TODO: Proper error messages
assert_eq!(a.major_dim(), b.major_dim(), "Patterns must have identical major dimensions."); assert_eq!(a.major_dim(), b.major_dim(), "Patterns must have identical major dimensions.");
assert_eq!(a.minor_dim(), b.minor_dim(), "Patterns must have identical minor dimensions."); assert_eq!(a.minor_dim(), b.minor_dim(), "Patterns must have identical minor dimensions.");
@ -39,6 +42,11 @@ pub fn spadd_pattern(a: &SparsityPattern,
/// ///
/// Assumes that the sparsity patterns both represent CSC matrices, and the result is also /// Assumes that the sparsity patterns both represent CSC matrices, and the result is also
/// represented as the sparsity pattern of a CSC matrix. /// represented as the sparsity pattern of a CSC matrix.
///
/// # Panics
///
/// Panics if the patterns, when interpreted as CSC patterns, are not compatible for
/// matrix multiplication.
pub fn spmm_csc_pattern(a: &SparsityPattern, b: &SparsityPattern) -> SparsityPattern { pub fn spmm_csc_pattern(a: &SparsityPattern, b: &SparsityPattern) -> SparsityPattern {
// Let C = A * B in CSC format. We note that // Let C = A * B in CSC format. We note that
// C^T = B^T * A^T. // C^T = B^T * A^T.
@ -52,6 +60,11 @@ pub fn spmm_csc_pattern(a: &SparsityPattern, b: &SparsityPattern) -> SparsityPat
/// ///
/// Assumes that the sparsity patterns both represent CSR matrices, and the result is also /// Assumes that the sparsity patterns both represent CSR matrices, and the result is also
/// represented as the sparsity pattern of a CSR matrix. /// represented as the sparsity pattern of a CSR matrix.
///
/// # Panics
///
/// Panics if the patterns, when interpreted as CSR patterns, are not compatible for
/// matrix multiplication.
pub fn spmm_csr_pattern(a: &SparsityPattern, b: &SparsityPattern) -> SparsityPattern { pub fn spmm_csr_pattern(a: &SparsityPattern, b: &SparsityPattern) -> SparsityPattern {
assert_eq!(a.minor_dim(), b.major_dim(), "a and b must have compatible dimensions"); assert_eq!(a.minor_dim(), b.major_dim(), "a and b must have compatible dimensions");

View File

@ -118,11 +118,6 @@ impl SparsityPattern {
major_offsets: Vec<usize>, major_offsets: Vec<usize>,
minor_indices: Vec<usize>, minor_indices: Vec<usize>,
) -> Result<Self, SparsityPatternFormatError> { ) -> Result<Self, SparsityPatternFormatError> {
// TODO: If these errors are *directly* propagated to errors from e.g.
// CSR construction, the error messages will be confusing to users,
// as the error messages refer to "major" and "minor" lanes, as opposed to
// rows and columns
use SparsityPatternFormatError::*; use SparsityPatternFormatError::*;
if major_offsets.len() != major_dim + 1 { if major_offsets.len() != major_dim + 1 {