Skip to content

Adding an Adjoint trait for operators #181

Open
@cjblocker

Description

@cjblocker

I am writing an optimization library for which I would like several of the routine's inputs to be generic LinearOperators. I was happy to find that this trait abstraction was already provided in ndarray-linalg, but some of my inputs additionally require that I can take an adjoint/hermitian transpose.

I've implemented this trait and its function on Array2, Diagonal, as well as my own LinearOperators (Identity, DFT), but as adjoints are a linear algebra concept, and linear operators in other languages often come with this functionality, I thought I'd see if there was any interest in a pull request.

Here is some example code. I could add into_adj() or adj_mut() if necessary.

pub trait Adjoint<'a>
{
    type Output;
    fn adj(&'a self) -> Self::Output;
}


impl<'a, A, S> Adjoint<'a> for ArrayBase<S, Ix2>
where
    A: 'a + Float,  // just the real case
    S: Data<Elem = A>,
{
    type Output = ArrayView<'a, A, Ix2>;

    fn adj(&'a self) ->  Self::Output {
        self.t()
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions