SOPT
Sparse OPTimisation
Functions
positive_quadrant_projection.cc File Reference
#include "sopt/maths.h"
#include "sopt/types.h"
+ Include dependency graph for positive_quadrant_projection.cc:

Go to the source code of this file.

Functions

int main (int, char const **)
 

Function Documentation

◆ main()

int main ( int  ,
char const **   
)

Definition at line 4 of file positive_quadrant_projection.cc.

4  {
5  // Create a matrix with a single negative real numbers
7  t_Matrix input = 2 * t_Matrix::Ones(5, 5) + t_Matrix::Random(5, 5);
8 
9  // Apply projection
10  t_Matrix posquad = sopt::positive_quadrant(input);
11  // imaginary part and negative real part becomes zero
12  if ((posquad.array().imag() != 0).any()) throw std::runtime_error("Imaginary part not zero");
13 
14  // positive real part unchanged
15  posquad.real()(2, 3) = input.real()(2, 3);
16  if ((posquad.array().real() != input.array().real()).all())
17  throw std::runtime_error("Real part was modified");
18 
19  return 0;
20 }
sopt::Matrix< Scalar > t_Matrix
Eigen::CwiseUnaryOp< const details::ProjectPositiveQuadrant< typename T::Scalar >, const T > positive_quadrant(Eigen::DenseBase< T > const &input)
Expression to create projection onto positive quadrant.
Definition: maths.h:60
Eigen::Array< T, Eigen::Dynamic, Eigen::Dynamic > Image
A 2-dimensional list of elements of given type.
Definition: types.h:39

References sopt::positive_quadrant().