Provide support for conjugate complex numbers

Issue #7 resolved
Klaus Iglberger created an issue

Description

Blaze provides support for complex numbers, but is missing the feature to compute the conjugate of a complex number. Also, Blaze does not yet provide the feature to compute the conjugate of a vector or matrix of complex numbers. Conceptually, the conj operation should work like this:

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) );

// Computing the matrix of complex conjugates
//    ( (1, 0)  (-2, 1) )
//    ( (1,-1)  ( 0,-1) )
StaticMatrix<cplx,2UL,2UL> B;
B = conj( A );

Tasks

  • provide the conj operation for scalars, including complex numbers
  • provide the conj operation for dense and sparse vectors
  • provide the conj 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 conj operation

Comments (4)

  1. Klaus Iglberger reporter
    • edited description

    The operations should be named conj as the according function in the standard library:

    std::complex<double> a( 2.0, -1.0 );
    std::complex<double> b( conj( a ) );  // Results in (2,1)
    
  2. Klaus Iglberger reporter

    The feature has been implemented, tested, optimized (including vectorization and parallelization) and documented as required. The following examples give an impression of the final feature:

    using blaze::StaticVector;
    
    typedef std::complex<double>  cplx;
    
    // Creating the vector
    //    ( (-2,-1) )
    //    ( ( 1, 1) )
    StaticVector<cplx,2UL> a( cplx(-2.0,-1.0), cplx(1.0,1.0) );
    
    // Computing the vector of complex conjugates
    //    ( (-2, 1) )
    //    ( ( 1,-1) )
    StaticVector<cplx,2UL> b;
    b = conj( 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) );
    
    // Computing the matrix of conjugate values
    //    ( (1, 0)  (-2, 1) )
    //    ( (1,-1)  ( 0,-1) )
    StaticMatrix<cplx,2UL,2UL> B;
    B = conj( A );
    

    The feature is immediately available via cloning the Blaze repository. It will be officially released in Blaze 2.5.

  3. Log in to comment