Provide an imag() function for vectors and matrices

Issue #18 resolved
Klaus Iglberger created an issue

Description

The standard library provides the imag function to access the imaginary part of complex numbers. In order to extend the support for complex numbers Blaze should provide a imag operation for vectors and matrices in order to compute the imaginary part of all elements. Conceptually, the imag operation should work like this:

using blaze::StaticVector;

typedef std::complex<double>  cplx;

// Creating the vector
//    ( (1,0)  (-2,-1) )
StaticVector<cplx,2UL> a( cplx(1.0,0.0), cplx(-2.0,-1.0) );

// Compute the imaginary part of all vector elements
//    ( 0  -1 )
StaticVector<double,2UL> b;
b = imag( a );
using blaze::StaticMatrix;

typedef std::complex<double>  cplx;

// Creating the matrix
//    ( (1,0)  (-2,-1) )
//    ( (1,1)  ( 0, 1) )
StaticMatrix<cplx,2UL,2UL> A( cplx(1.0,0.0), cplx(-2.0,-1.0),
                              cplx(1.0,1.0), cplx( 0.0, 1.0) );

// Compute the imaginary part of all matrix elements
//    ( 0  -1 )
//    ( 1   1 )
StaticMatrix<double,2UL,2UL> B;
B = imag( A );

Tasks

  • provide the imag operation for scalars, including complex numbers
  • provide the imag operation for dense and sparse vectors
  • provide the imag operation for dense and sparse matrices
  • provide a full documentation of the operation
  • ensure compatibility to all existing vector and matrix classes
  • ensure compatibility to all existing vector and matrix expressions
  • guarantee maximum performance for the operation
  • extend existing test cases to also cover the imag operation

Comments (4)

  1. Klaus Iglberger reporter

    The feature has been implemented, tested, optimized (including parallelization) and documented as required. The feature is immediately available via cloning the Blaze repository. It will be officially released in Blaze 2.5.

  2. Log in to comment