-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
0 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1 @@ | ||
//! Traits for the creation of new entities. | ||
|
||
/// Create a new object from `self` initialized to zero. | ||
pub trait NewLikeSelf { | ||
type Out; | ||
fn new_like_self(&self) -> Self::Out; | ||
} | ||
|
||
/// Create a new object from `self` with dimensions transposed. | ||
pub trait NewLikeTranspose { | ||
type Out; | ||
fn new_like_transpose(&self) -> Self::Out; | ||
} | ||
|
||
/// Evaluate a matrix/vector expression into a new matrix/vector. | ||
pub trait Eval { | ||
type Out; | ||
fn eval(&self) -> Self::Out; | ||
} | ||
|
||
/// Copy a matrix/vector expression into a new matrix/vector. | ||
pub trait Copy { | ||
type Out; | ||
fn copy(&self) -> Self::Out; | ||
} | ||
|
||
pub trait Identity { | ||
type Out; | ||
|
||
/// Return an identity matrix with given shape. | ||
fn identity(shape: (usize, usize)) -> Self::Out; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1 @@ | ||
//! Traits for in-place operations. | ||
|
||
use crate::types::Scalar; | ||
|
||
/// Scale the object by a given factor. | ||
pub trait ScaleInPlace { | ||
type Item: Scalar; | ||
|
||
fn scale_in_place(&mut self, alpha: Self::Item); | ||
} | ||
|
||
/// Fill the object from `other`. | ||
pub trait FillFrom<Other> { | ||
fn fill_from(&mut self, other: Other); | ||
} | ||
|
||
/// Add `alpha * other` to `self`. | ||
pub trait SumInto<Other> { | ||
fn sum_into(&mut self, other: Other); | ||
} | ||
|
||
/// Set the diagonal of an object from a given iterator. | ||
pub trait SetDiag { | ||
type Item: Scalar; | ||
|
||
/// Set the diagonal from an iterator. | ||
/// | ||
/// The method sets the diagonal from the iterator up to the minimum of iterator | ||
/// length or number of diagonal elements. | ||
fn set_diag_from_iter<I: Iterator<Item = Self::Item>>(&mut self, iter: I); | ||
|
||
/// Set the diagonal from a given slice. | ||
/// | ||
/// Produces an error if the length of the slice is not identical to | ||
/// the length of the diagonal. | ||
fn set_diag_from_slice(&mut self, diag: &[Self::Item]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1 @@ | ||
//! Traits for operations that do not change `self`. | ||
|
||
use crate::types::Scalar; | ||
use rlst_blis::interface::types::TransMode; | ||
|
||
/// Take the sum with `other`. | ||
pub trait Sum<Other> { | ||
type Out; | ||
|
||
fn sum(&self, other: &Other) -> Self::Out; | ||
} | ||
|
||
/// Subtract `other` from `self`. | ||
pub trait Sub<Other> { | ||
type Out; | ||
|
||
fn sub(&self, other: &Other) -> Self::Out; | ||
} | ||
|
||
/// Compute `y -> alpha * self + beta y`. | ||
pub trait Apply<Domain> { | ||
type T: Scalar; | ||
type Out; | ||
|
||
fn apply(&self, alpha: Self::T, x: &Domain, y: &mut Self::Out, beta: Self::T); | ||
} | ||
|
||
/// Compute the 1-norm of an object. | ||
pub trait Norm1 { | ||
type T: Scalar; | ||
|
||
fn norm1(&self) -> <Self::T as Scalar>::Real; | ||
} | ||
|
||
/// Compute the inf-norm of an object. | ||
pub trait NormInf { | ||
type T: Scalar; | ||
|
||
fn norm_inf(&self) -> <Self::T as Scalar>::Real; | ||
} | ||
|
||
/// Compute the inner product of an object with `other`. | ||
/// The convention for complex objects is that the complex-conjugate | ||
/// of `other` is taken for the inner product. | ||
pub trait Inner { | ||
type T: Scalar; | ||
|
||
fn inner(&self, other: &Self) -> Self::T; | ||
} | ||
|
||
/// Compute a dual form of an object with `other`. | ||
/// The convention for complex objecdts is that the complex-conjugate | ||
/// of `other` is taken when appropriate for the dual form. | ||
pub trait Dual { | ||
type T: Scalar; | ||
type Other; | ||
|
||
fn dual(&self, other: &Self::Other) -> Self::T; | ||
} | ||
|
||
/// Compute the sum of squares of the absolute values of the entries. | ||
pub trait SquareSum { | ||
type T: Scalar; | ||
|
||
fn square_sum(&self) -> <Self::T as Scalar>::Real; | ||
} | ||
|
||
/// Transpose of an operator | ||
pub trait Transpose { | ||
type Out; | ||
|
||
fn transpose(self) -> Self::Out; | ||
} | ||
|
||
/// Take the conjugate of a matrix. | ||
pub trait Conjugate { | ||
type Out; | ||
|
||
fn conj(self) -> Self::Out; | ||
} | ||
|
||
/// Componentwise product with an other object. | ||
pub trait CmpWiseProduct<Other> { | ||
type Out; | ||
|
||
fn cmp_wise_product(self, other: Other) -> Self::Out; | ||
} | ||
|
||
/// Conjugate transpose of an operator. | ||
pub trait ConjTranspose<Out> { | ||
fn conj_transpose(self) -> Out; | ||
} | ||
|
||
/// Convert operator to complex. | ||
pub trait ToComplex { | ||
type Out; | ||
fn to_complex(self) -> Self::Out; | ||
} | ||
|
||
/// Check if operator is Hermititan. | ||
pub trait IsHermitian { | ||
fn is_hermitian(&self) -> bool; | ||
} | ||
|
||
/// Check if operator is symmetric. | ||
pub trait IsSymmetric { | ||
fn is_symmetric(&self) -> bool; | ||
} | ||
|
||
/// Permute the columns of an operator | ||
/// | ||
/// `permutation` is a permutation vector such | ||
/// that if permutation\[i\] = k | ||
/// then the ith column of the output matrix | ||
/// is the kth column of the input matrix. | ||
pub trait PermuteColumns { | ||
type Out; | ||
|
||
fn permute_columns(&self, permutation: &[usize]) -> Self::Out; | ||
} | ||
|
||
/// Permute the rows of an operator | ||
/// | ||
/// `permutation` is a permutation vector such | ||
/// that if permutation\[i\] = k | ||
/// then the ith row of the output matrix | ||
/// is the kth row of the input matrix. | ||
pub trait PermuteRows { | ||
type Out; | ||
|
||
fn permute_rows(&self, permutation: &[usize]) -> Self::Out; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters