27   , mNodataValue( nodataValue )
    46   int nEntries = mColumns * mRows;
    47   mData = 
new double[nEntries];
    48   memcpy( mData, m.mData, 
sizeof( 
double ) * nEntries );
    73   return twoArgumentOperation( 
opPLUS, other );
    78   return twoArgumentOperation( 
opMINUS, other );
    83   return twoArgumentOperation( 
opMUL, other );
    88   return twoArgumentOperation( 
opDIV, other );
    93   return twoArgumentOperation( 
opPOW, other );
    98   return twoArgumentOperation( 
opEQ, other );
   103   return twoArgumentOperation( 
opNE, other );
   108   return twoArgumentOperation( 
opGT, other );
   113   return twoArgumentOperation( 
opLT, other );
   118   return twoArgumentOperation( 
opGE, other );
   123   return twoArgumentOperation( 
opLE, other );
   128   return twoArgumentOperation( 
opAND, other );
   133   return twoArgumentOperation( 
opOR, other );
   138   return twoArgumentOperation( 
opMAX, other );
   143   return twoArgumentOperation( 
opMIN, other );
   148   return oneArgumentOperation( 
opSQRT );
   153   return oneArgumentOperation( 
opSIN );
   158   return oneArgumentOperation( 
opASIN );
   163   return oneArgumentOperation( 
opCOS );
   168   return oneArgumentOperation( 
opACOS );
   173   return oneArgumentOperation( 
opTAN );
   178   return oneArgumentOperation( 
opATAN );
   183   return oneArgumentOperation( 
opSIGN );
   188   return oneArgumentOperation( 
opLOG );
   193   return oneArgumentOperation( 
opLOG10 );
   198   return oneArgumentOperation( 
opABS );
   208   int nEntries = mColumns * mRows;
   210   for ( 
int i = 0; i < nEntries; ++i )
   213     if ( value != mNodataValue )
   220             mData[i] = mNodataValue;
   224             mData[i] = std::sqrt( value );
   228           mData[i] = std::sin( value );
   231           mData[i] = std::cos( value );
   234           mData[i] = std::tan( value );
   237           mData[i] = std::asin( value );
   240           mData[i] = std::acos( value );
   243           mData[i] = std::atan( value );
   251             mData[i] = mNodataValue;
   255             mData[i] = 
::log( value );
   261             mData[i] = mNodataValue;
   269           mData[i] = ::fabs( value );
   277 double QgsRasterMatrix::calculateTwoArgumentOp( 
TwoArgOperator op, 
double arg1, 
double arg2 )
 const   297       if ( !testPowerValidity( arg1, arg2 ) )
   303         return std::pow( arg1, arg2 );
   306       return ( arg1 == arg2 ? 1.0 : 0.0 );
   308       return ( arg1 == arg2 ? 0.0 : 1.0 );
   310       return ( arg1 > arg2 ? 1.0 : 0.0 );
   312       return ( arg1 < arg2 ? 1.0 : 0.0 );
   314       return ( arg1 >= arg2 ? 1.0 : 0.0 );
   316       return ( arg1 <= arg2 ? 1.0 : 0.0 );
   318       return ( arg1 && arg2 ? 1.0 : 0.0 );
   320       return ( arg1 || arg2 ? 1.0 : 0.0 );
   322       return std::max( arg1, arg2 );
   324       return std::min( arg1, arg2 );
   336       mData[0] = mNodataValue;
   340       mData[0] = calculateTwoArgumentOp( op, mData[0], other.
number() );
   348     double *matrix = other.mData;
   349     int nEntries = mColumns * mRows;
   350     double value1, value2;
   352     for ( 
int i = 0; i < nEntries; ++i )
   356       if ( value1 == mNodataValue || value2 == other.mNodataValue )
   358         mData[i] = mNodataValue;
   362         mData[i] = calculateTwoArgumentOp( op, value1, value2 );
   371     double *matrix = other.mData;
   373     double value = mData[0];
   375     mData = 
new double[nEntries];
   377     mRows = other.
nRows();
   380     if ( value == mNodataValue )
   382       for ( 
int i = 0; i < nEntries; ++i )
   384         mData[i] = mNodataValue;
   389     for ( 
int i = 0; i < nEntries; ++i )
   391       if ( matrix[i] == other.mNodataValue )
   393         mData[i] = mNodataValue;
   397       mData[i] = calculateTwoArgumentOp( op, value, matrix[i] );
   403     double value = other.
number();
   404     int nEntries = mColumns * mRows;
   406     if ( other.
number() == other.mNodataValue )
   408       for ( 
int i = 0; i < nEntries; ++i )
   410         mData[i] = mNodataValue;
   415     for ( 
int i = 0; i < nEntries; ++i )
   417       if ( mData[i] == mNodataValue )
   422       mData[i] = calculateTwoArgumentOp( op, mData[i], value );
   428 bool QgsRasterMatrix::testPowerValidity( 
double base, 
double power )
 const   430   return !( ( base == 0 && power < 0 ) || ( base < 0 && ( power - std::floor( power ) ) > 0 ) );
 double * takeData()
Returns data and ownership. 
 
bool isNumber() const
Returns true if matrix is 1x1 (=scalar number) 
 
QgsRasterMatrix & operator=(const QgsRasterMatrix &m)
 
bool add(const QgsRasterMatrix &other)
Adds another matrix to this one. 
 
double nodataValue() const
 
bool power(const QgsRasterMatrix &other)
 
bool absoluteValue()
Calculates the absolute value. 
 
bool greaterThan(const QgsRasterMatrix &other)
 
bool notEqual(const QgsRasterMatrix &other)
 
bool equal(const QgsRasterMatrix &other)
 
bool logicalOr(const QgsRasterMatrix &other)
 
void setData(int cols, int rows, double *data, double nodataValue)
 
QgsRasterMatrix()=default
Takes ownership of data array. 
 
bool subtract(const QgsRasterMatrix &other)
Subtracts another matrix from this one. 
 
bool multiply(const QgsRasterMatrix &other)
 
bool lesserEqual(const QgsRasterMatrix &other)
 
bool divide(const QgsRasterMatrix &other)
 
bool greaterEqual(const QgsRasterMatrix &other)
 
bool min(const QgsRasterMatrix &other)
Calculates the minimum value between two matrices. 
 
bool max(const QgsRasterMatrix &other)
Calculates the maximum value between two matrices. 
 
double * data()
Returns data array (but not ownership) 
 
bool lesserThan(const QgsRasterMatrix &other)
 
bool logicalAnd(const QgsRasterMatrix &other)