⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix.h

📁 大地测量专业计算软件
💻 H
📖 第 1 页 / 共 5 页
字号:
    
    \code
    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();        // Print Matrix A.
    result = A.Inplace_AddScalar(1); // A += 1.
    cout << endl;
    result = A.PrintStdout();        // Print Matrix A. A = "[2 3 4; 5 6 7; 8 9 10]";
    \endcode    
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_AddScalar( const double scalar );

    /**
    \brief  Subtract a scaler double (ie: M -= 5).
    
    \code
    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();             // Print Matrix A.
    result = A.Inplace_SubtractScalar(1); // A -= 1.
    cout << endl;
    result = A.PrintStdout();             // Print Matrix A. A = "[0 1 2; 3 4 5; 6 7 8]";
    \endcode    
       
    \return true if successful, false otherwise.    
    */
    bool Inplace_SubtractScalar( const double scalar );

    /**
    \brief  Multiply by scaler double (ie: M *= 5).
    
    \code
    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();              // Print Matrix A.
    result = A.Inplace_MultiplyScalar(5);  // A *= 5.
    cout << endl;
    result = A.PrintStdout();              // Print Matrix A. A = "[5 10 15; 20 25 30; 35 40 45]";
    \endcode    
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_MultiplyScalar( const double scalar );

    /**
    \brief  Divide by scaler double (ie: M /= 5).
    
    \code
    Matrix A;
    A = "[5 10 15; 20 25 30; 35 40 45]";
    bool result;
    result = A.PrintStdout();           // Print Matrix A.
    result = A.Inplace_DivideScalar(5); // A /= 5.
    cout << endl;
    result = A.PrintStdout();           // Print Matrix A. A = "[1 2 3; 4 5 6; 7 8 9]";
    \endcode    
       
    \return true if successful, false otherwise.    
    */
    bool Inplace_DivideScalar( const double scalar );

    /**
    \brief  Raise the matrix to a power scaler double (ie: M ^= 5).
    
    \code
    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();           // Print Matrix A.
    result = A.Inplace_PowerScalar(2);  // A = A.^2. Not A*A! Each element is raised.
    cout << endl;
    result = A.PrintStdout();           // Print Matrix A. A = "[1 4 9; 16 25 36; 49 64 81]";
    \endcode    
           
    \return true if successful, false otherwise.    
    */
    bool Inplace_PowerScalar( const double scalar );

    /**
    \brief  Add a scaler double (ie: M += (4+2i)).
    
    \code
    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();           // Print Matrix A.
    std::complex<double> cplx(4.0,2.0);
    result = A.Inplace_AddScalarComplex(cplx);  // A += (4+2i).
    cout << endl;
    result = A.PrintStdout();           // Print Matrix A. A = "[5+2i 6+2i 7+2i; 8+2i 9+2i 10+2i; 11+2i 12+2i 13+2i]";
    cout << "A(0,0) = " << A(0,0).real() << "+" << A(0,0).imag() << "i " << endl;
    \endcode    
               
    * \return true if successful, false otherwise.    
    */
    bool Inplace_AddScalarComplex( const std::complex<double> cplx );

    /**
    \brief  Subtract a scaler double (ie: M -= (5+2i)).
    
    \code
    Matrix A;
    A = "[1 2 3; 4 5 6; 7 8 9]";
    bool result;
    result = A.PrintStdout();           // Print Matrix A.
    std::complex<double> cplx(5.0,2.0);
    result = A.Inplace_SubtractScalarComplex(cplx);  // A -= (5+2i).
    cout << endl;
    result = A.PrintStdout();           // Print Matrix A. A = "[-4-2i -3-2i -2-2i; -1-2i 0-2i 1-2i; 2-2i 3-2i 4-2i]";
    cout << "A(0,0) = " << A(0,0).real() << "+" << A(0,0).imag() << "i " << endl;
    \endcode    
                   
    \return true if successful, false otherwise.    
    */
    bool Inplace_SubtractScalarComplex( const std::complex<double> cplx );

    /**
    \brief  Multiply by scaler double (ie: M *= (5+2i)).

    \code
    Matrix M;
    M = "[10 20]";
    std::complex<double> cplx(5,2);
    if( !M.Inplace_MultiplyScalarComplex(cplx) )
      return false;
    // M
    // 50+20i  100+40i
    \endcode
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_MultiplyScalarComplex( const std::complex<double> cplx );

    /**
    \brief  Divide by scaler double (ie: M /= (5+1i)).

    \code
    Matrix M;
    M = "[10+2i 20+4i]";
    std::complex<double> cplx(5,1);
    if( !M.Inplace_DivideScalarComplex(cplx) )
      return false;
    // M
    // 2  4
    \endcode
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_DivideScalarComplex( const std::complex<double> cplx );

    /**
    \brief  Raise the matrix to a power scaler double (ie: M ^= (5+2i)).

    \code
    Matrix M;
    M = "[2 3]";
    std::complex<double> cplx(5,2);
    if( !M.Inplace_PowerScalarComplex(cplx) )
      return false;
    // M
    // 5.87062319178566+31.4568876931598i    -142.459949032798+196.860770397691i
    \endcode    
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_PowerScalarComplex( const std::complex<double> cplx );

    /**
    \brief  Compute the absolute value of each element in the matrix.

    \code
    Matrix A;
    A = "[-1 -2; -3 -4]";
    if( !A.Inplace_Abs() )
      return false;
    // A
    // 1 2
    // 3 4
    \endcode
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_Abs();

    /**
    \brief  Compute the value^2 of each element in the matrix.

    \code
    Matrix A;
    A = "[1 2; -3 -4]";
    if( !A.Inplace_Sqr() )
      return false;
    // A
    // 1 4
    // 9 16
    \endcode    
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_Sqr();

    /**
    \brief  Computes the sqrt(value) of each element in the matrix.

    \code
    Matrix A;
    A = "[1 4; 9 16]";
    if( !A.Inplace_Sqrt() )
      return false;
    // A
    // 1 2
    // 3 4
    \endcode        
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_Sqrt();

    /**
    \brief  Computes the exp(value) of each element in the matrix.

    \code
    Matrix A;
    A = "[1 2; 3 4]";
    if( !A.Inplace_Exp() )
      return false;
    // A ~
    //  2.71828  7.38905
    // 20.08553 54.59815
    \endcode        
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_Exp();

    /**
    \brief  Computes the natural logarithm, ln(value) of each element in the matrix.

    \code
    Matrix A;
    A = "[2.71828  7.38905; 20.08553 54.59815]";    
    if( !A.Inplace_Ln() )
      return false;
    // A ~
    // 1 2
    // 3 4
    \endcode         
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_Ln();

    /**
    \brief  Add +1.0 to all elements, e.g. M++.

    \code
    Matrix A;
    A = "[1 2; 3 4]";
    if( !A.Inplace_Increment() )
      return false;
    // A 
    // 2 3
    // 4 5
    \endcode        
    
    \return true if successful, false otherwise.   
    */
    bool Inplace_Increment();

    /**
    \brief  Subtract 1.0 from all elements, e.g. M--.

    \code
    Matrix A;
    A = "[1 2; 3 4]";
    if( !A.Inplace_Decrement() )
      return false;
    // A 
    // 0 1
    // 2 3
    \endcode            
    
    \return true if successful, false otherwise.    
    */
    bool Inplace_Decrement();

    /**
    \brief  Add matrix B to this matrix inplace. A += B, inplace.

    \code
    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 3 4]";
    if( !A.Inplace_Add(B) )
      return false;
    // A 
    // 2 4
    // 6 8
    \endcode            
    
    \return true if successful, false otherwise.
    */
    bool Inplace_Add( const Matrix &B );

    /**
    \brief  Subtract matrix B from this matrix inplace. A -= B, inplace.

    \code
    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 3 4]";
    if( !A.Inplace_Subtract(B) )
      return false;
    // A 
    // 0 0
    // 0 0
    \endcode            
    
    \return true if successful, false otherwise.
    */
    bool Inplace_Subtract( const Matrix &B );

    /**
    \brief  Pre-Multiply this matrix by B. A = B*A, inplace.

    \code
    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 2 1]";
    if( !A.Inplace_PreMultiply(B) )
      return false;
    // A 
    // 7 10
    // 5 8
    \endcode  
    
    \return true if successful, false otherwise.
    */
    bool Inplace_PreMultiply( const Matrix &B );

    /**
    \brief  Pre-Multiply this matrix by tranpose(B). A = tranpose(B)*A, inplace.
    No transpose occurs and hence more efficient.

    \code
    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[5 6; 7 8]";
    if( !A.Inplace_TranposePreMultiply(B) )
      return false;
    // A 
    // 26 38
    // 30 44
    \endcode  
    
    \return true if successful, false otherwise.
    */
    bool Inplace_TranposePreMultiply( const Matrix &B );

    /**
    \brief  Post-Multiply this matrix by B. A = A*B, inplace.

    \code
    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 2 1]";
    if( !A.Inplace_PostMultiply(B) )
      return false;
    // A 
    // 5 4
    // 11 10
    \endcode      
    
    \return true if successful, false otherwise.  
    */
    bool Inplace_PostMultiply( const Matrix &B );

    /**
    \brief  Post-Multiply this matrix by transpose(B). A = A*transpose(B), inplace.

    \code
    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[5 6; 7 8]";
    if( !A.Inplace_PostMultiplyTranspose(B) )
      return false;
    // A 
    // 17 23
    // 39 53
    \endcode      
    
    \return true if successful, false otherwise.  
    */
    bool Inplace_PostMultiplyTranspose( const Matrix &B );

    /**
    \brief  Dot multiply A .*= B, inplace. A and B must have the same dimensions.

    \code
    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 2 1]";
    if( !A.Inplace_DotMultiply(B) )
      return false;
    // A 
    // 1 4
    // 6 4
    \endcode          
    
    \return true if successful, false otherwise.
    */
    bool Inplace_DotMultiply( const Matrix &B );

    /**
    \brief  Dot divide A ./= B, inplace. A and B must have the same dimensions.

    \code
    Matrix A;
    Matrix B;
    A = "[1 2; 3 4]";
    B = "[1 2; 2 1]";
    if( !A.Inplace_DotDivide(B) )
      return false;
    // A 
    // 1   1
    // 1.5 4
    \endcode          
    
    \return true if successful, false otherwise.
    */
    bool Inplace_DotDivide( const Matrix &B );

    /**
    \brief  Sorts each column of the matrix in ascending order.
            If complex, sorts based on magnitude.
    \code
    Matrix A;
    A = "[1;3;2;4;6;5;7]";
    if( !A.Inplace_SortAscending() )
      return false;
    // A
    // [1;2;3;4;5;6;7]
    \endcode
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -