Skip to content

Commit

Permalink
rlst-dense is cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
tbetcke committed Dec 3, 2023
1 parent d80e827 commit 8643f46
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 249 deletions.
31 changes: 0 additions & 31 deletions common/src/traits/constructors.rs
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;
}
36 changes: 0 additions & 36 deletions common/src/traits/in_place_operations.rs
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]);
}
47 changes: 0 additions & 47 deletions common/src/traits/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,3 @@ pub trait AijIterator {

fn iter_aij(&self) -> Self::Iter<'_>;
}

/// Iterate through the elements in column-major ordering.
pub trait ColumnMajorIterator {
type Item: Scalar;
type Iter<'a>: std::iter::Iterator<Item = Self::Item>
where
Self: 'a;

fn iter_col_major(&self) -> Self::Iter<'_>;
}

/// Mutable iterator through the elements in column-major ordering.
pub trait ColumnMajorIteratorMut {
type Item: Scalar;
type IterMut<'a>: std::iter::Iterator<Item = &'a mut Self::Item>
where
Self: 'a;

fn iter_col_major_mut(&mut self) -> Self::IterMut<'_>;
}

/// Iterate through the diagonal.
pub trait DiagonalIterator {
type Item: Scalar;
type Iter<'a>: std::iter::Iterator<Item = Self::Item>
where
Self: 'a;

fn iter_diag(&self) -> Self::Iter<'_>;
}

/// Mutable iterator through the diagonal.
pub trait DiagonalIteratorMut {
type Item: Scalar;
type IterMut<'a>: std::iter::Iterator<Item = &'a mut Self::Item>
where
Self: 'a;

fn iter_diag_mut(&mut self) -> Self::IterMut<'_>;
}

/// Apply an `FnMut` closure to each element.
pub trait ForEach {
type Item: Scalar;

fn for_each<F: FnMut(&mut Self::Item)>(&mut self, f: F);
}
131 changes: 0 additions & 131 deletions common/src/traits/operations.rs
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;
}
1 change: 0 additions & 1 deletion dense/src/array/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use crate::layout::convert_1d_nd_from_shape;

use super::*;
use rlst_common::traits::*;

impl<
Item: Scalar,
Expand Down
1 change: 0 additions & 1 deletion dense/src/linalg/pseudo_inverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::rlst_dynamic_array2;
use crate::traits::*;
use itertools::Itertools;
use num::traits::{One, Zero};
use rlst_common::traits::*;
use rlst_common::types::{c32, c64, RlstResult, Scalar};

macro_rules! impl_pinv {
Expand Down
1 change: 0 additions & 1 deletion dense/src/matrix_multiply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! This module implements the matrix multiplication. The current implementation
//! uses the [rlst-blis] crate.
use crate::traits::*;
use crate::traits::*;
use rlst_blis::interface::gemm::Gemm;
use rlst_blis::interface::types::TransMode;
Expand Down
1 change: 0 additions & 1 deletion dense/src/tools.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Useful library tools.
use crate::traits::*;
use crate::traits::*;
use rand::prelude::*;
use rand_distr::Distribution;
Expand Down

0 comments on commit 8643f46

Please sign in to comment.