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

📄 matrix.cpp

📁 矩阵类
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    if( MTX_Min( &m_Matrix, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_MinAbsCol(const unsigned col, double &value, unsigned &row )
  {
    if( MTX_MinAbsColIndex( &m_Matrix, col, &value, &row ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_MinCol(const unsigned col, double &re, double &im, unsigned &row )
  {
    if( MTX_MinColIndex( &m_Matrix, col, &re, &im, &row ) )
      return true;
    else 
      return false;
  }


  bool Matrix::GetStats_MinColVal(const unsigned col, double &re, double &im )
  {
    if( MTX_MinColumn( &m_Matrix, col, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_MinAbsRow(const unsigned row, double &value, unsigned &col )
  {
    if( MTX_MinAbsRowIndex( &m_Matrix, row, &value, &col ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_MinRow(const unsigned row, double &re, double &im, unsigned &col )
  {
    if( MTX_MinRowIndex( &m_Matrix, row, &re, &im, &col ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_MinRowVal(const unsigned row, double &re, double &im )
  {
    if( MTX_MinRow(  &m_Matrix, row, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_ColRange( const unsigned col, double &re, double &im )
  {
    if( MTX_ColumnRange( &m_Matrix, col, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RowRange( const unsigned row, double &re, double &im )
  {
    if( MTX_RowRange( &m_Matrix, row, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_Range( double &re, double &im )
  {
    if( MTX_Range( &m_Matrix, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_ColumnSum( const unsigned col, double &re, double &im )
  {
    if( MTX_ColumnSum( &m_Matrix, col, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RowSum( const unsigned row, double &re, double &im )
  {
    if( MTX_RowSum( &m_Matrix, row, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_Sum( double &re, double &im )
  {
    if( MTX_Sum( &m_Matrix, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_ColumnMean( const unsigned col, double &re, double &im )
  {
    if( MTX_ColumnMean( &m_Matrix, col, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RowMean( const unsigned row, double &re, double &im )
  {
    if( MTX_RowMean( &m_Matrix, row, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_Mean( double &re, double &im )
  {
    if( MTX_Mean( &m_Matrix, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_ColumnStdev( const unsigned col, double &value )
  {
    if( MTX_ColumnStdev( &m_Matrix, col, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RowStdev( const unsigned row, double &value )
  {
    if( MTX_RowStdev( &m_Matrix, row, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_Stdev( double &value )
  {
    if( MTX_Stdev( &m_Matrix, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_ColumnVar( const unsigned col, double &value )
  {
    if( MTX_ColumnVar( &m_Matrix, col, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RowVar( const unsigned row, double &value )
  {
    if( MTX_RowVar( &m_Matrix, row, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_Var( double &value )
  {
    if( MTX_Var( &m_Matrix, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_ColumnNorm( const unsigned col, double &value )
  {
    if( MTX_ColumnNorm( &m_Matrix, col, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RowNorm( const unsigned row, double &value )
  {
    if( MTX_RowNorm( &m_Matrix, row, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_Norm( double &value )
  {
    if( MTX_Norm( &m_Matrix, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_ColumnRMS( const unsigned col, double &value )
  {
    if( MTX_ColumnRMS( &m_Matrix, col, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RowRMS( const unsigned row, double &value )
  {
    if( MTX_RowRMS( &m_Matrix, row, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RMS( double &value )
  {
    if( MTX_RMS( &m_Matrix, &value ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_ColumnSkewness( const unsigned col, double &re, double &im )
  {
    if( MTX_ColumnSkewness( &m_Matrix, col, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RowSkewness( const unsigned row, double &re, double &im )
  {
    if( MTX_RowSkewness( &m_Matrix, row, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_Skewness( double &re, double &im )
  {
    if( MTX_Skewness( &m_Matrix, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_ColumnKurtosis( const unsigned col, double &re, double &im )
  {
    if( MTX_ColumnKurtosis( &m_Matrix, col, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_RowKurtosis( const unsigned row, double &re, double &im )
  {
    if( MTX_RowKurtosis( &m_Matrix, row, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetStats_Kurtosis( double &re, double &im )
  {
    if( MTX_Kurtosis( &m_Matrix, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetTrace( double &re, double &im )
  {
    if( MTX_Trace( &m_Matrix, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetDeterminant( double &re, double &im )
  {
    if( MTX_Det( &m_Matrix, &re, &im ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetDiagonal( Matrix& DiagonalVector )
  {
    if( MTX_Diagonal( &m_Matrix, &DiagonalVector.m_Matrix ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetColumnMovAvg( const unsigned col, const unsigned lead, const unsigned lag, Matrix &MovAvg )
  {
    if( MTX_ColumnMovAvg( &m_Matrix, col, lead, lag, &MovAvg.m_Matrix ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetMovAvg( const unsigned lead, const unsigned lag, Matrix &MovAvg )
  {
    if( MTX_MovAvg( &m_Matrix, lead, lag, &MovAvg.m_Matrix ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetATAInverse( Matrix &InvATA )
  {
    if( MTX_ATAInverse( &m_Matrix, &InvATA.m_Matrix ) )
      return true;
    else 
      return false;
  }

  bool Matrix::GetLUFactorization( bool &isFullRank, Matrix &P, Matrix &L, Matrix &U )
  {
    BOOL b_isFullRank;
    if( MTX_LUFactorization( &m_Matrix, &b_isFullRank, &P.m_Matrix, &L.m_Matrix, &U.m_Matrix ) )
    {
      if( b_isFullRank )
        isFullRank = true;
      else
        isFullRank = false;

      return true;
    }
    else 
    {
      if( b_isFullRank )
        isFullRank = true;
      else
        isFullRank = false;

      return false;
    }
  }

  bool Matrix::GetIndexedValues( Matrix& RowIndex, Matrix& ColIndex, Matrix& Result )
  {
    Matrix _rowIndex; // a copy if needed
    Matrix _colIndex; // a copy if needed
    if( !RowIndex.m_Matrix.isReal )
    {
      if( !MTX_Real( &RowIndex.m_Matrix, &_rowIndex.m_Matrix ) )
        return false;
    }
    if( !ColIndex.m_Matrix.isReal )
    {
      if( !MTX_Real( &ColIndex.m_Matrix, &_colIndex.m_Matrix ) )
        return false;
    }

    if( !_rowIndex.isEmpty() )
    {
      if( !_colIndex.isEmpty() )
      {
        if( MTX_IndexedValues( &m_Matrix, &_rowIndex.m_Matrix, &_colIndex.m_Matrix, &Result.m_Matrix ) )
          return true;
        else
          return false;
      }
      else
      {
        if( MTX_IndexedValues( &m_Matrix, &_rowIndex.m_Matrix, &ColIndex.m_Matrix, &Result.m_Matrix ) )
          return true;
        else
          return false;
      }
    }
    else
    {
      if( !_colIndex.isEmpty() )
      {
        if( MTX_IndexedValues( &m_Matrix, &RowIndex.m_Matrix, &_colIndex.m_Matrix, &Result.m_Matrix ) )
          return true;
        else
          return false;
      }
      else
      {
        if( MTX_IndexedValues( &m_Matrix, &RowIndex.m_Matrix, &ColIndex.m_Matrix, &Result.m_Matrix ) )
          return true;
        else
          return false;
      }
    }    
  }


  bool Matrix::SetIndexedValues( Matrix& RowIndex, Matrix& ColIndex, Matrix& SourceData )
  {
    Matrix _rowIndex; // a copy if needed
    Matrix _colIndex; // a copy if needed
    if( !RowIndex.m_Matrix.isReal )
    {
      if( !MTX_Real( &RowIndex.m_Matrix, &_rowIndex.m_Matrix ) )
        return false;
    }
    if( !ColIndex.m_Matrix.isReal )
    {
      if( !MTX_Real( &ColIndex.m_Matrix, &_colIndex.m_Matrix ) )
        return false;
    }

    if( !_rowIndex.isEmpty() )
    {
      if( !_colIndex.isEmpty() )
      {
        if( MTX_SetIndexedValues( &m_Matrix, &_rowIndex.m_Matrix, &_colIndex.m_Matrix, &SourceData.m_Matrix ) )
          return true;
        else
          return false;
      }
      else
      {
        if( MTX_SetIndexedValues( &m_Matrix, &_rowIndex.m_Matrix, &ColIndex.m_Matrix, &SourceData.m_Matrix ) )
          return true;
        else
          return false;
      }
    }
    else
    {
      if( !_colIndex.isEmpty() )
      {
        if( MTX_SetIndexedValues( &m_Matrix, &RowIndex.m_Matrix, &_colIndex.m_Matrix, &SourceData.m_Matrix ) )
          return true;
        else
          return false;
      }
      else
      {
        if( MTX_SetIndexedValues( &m_Matrix, &RowIndex.m_Matrix, &ColIndex.m_Matrix, &SourceData.m_Matrix ) )
          return true;
        else
          return false;
      }
    }    
  }


  std::string Matrix::GetMatrixComment()
  {
    std::string result;
    if( m_Matrix.comment != NULL )
      result = m_Matrix.comment;
    
    return result;
  }


  bool Matrix::TimeWindow( 
    const unsigned timeColumn, //!< The column containing time.
    const double startTime,    //!< The specified start time (inclusive).
    const double duration,     //!< The duration to include.
    const double rolloverTime  //!< The potential time at which system time rolls over.
    )
  {
    if( MTX_TimeWindow(
      &m_Matrix, 
      timeColumn, 
      startTime,
      duration,
      rolloverTime ) )
      return true;
    else 
      return false;
  }

  bool Matrix::TimeLimit( 
    const unsigned timeColumn, //!< The column containing time
    const double startTime,    //!< The specified start time (inclusive)
    const double endTime       //!< The duration to include
    )
  {
    if( MTX_TimeLimit(
      &m_Matrix,
      timeColumn,
      startTime,
      endTime ) )
      return true;
    else 
      return false;
  }

  bool Matrix::TimeMatch( 
    Matrix &A,                   //!< The matrix with interpolation times
    const unsigned timeColumnA,  //!< The zero based column index for matrix A
    Matrix &B,                   //!< The matrix to be interpolated
    const unsigned timeColumnB,  //!< The zero based column index for matrix B
    const unsigned precision,    //!< The rounding precision used for time matching, 0 = whole, 1 = 0.1, 2 = 0.01, etc
    const double rolloverTime    //!< The rollover time, e.g. 60 s for minute based timing, 0.0 means rollovers not allowed
    )
  {
    // check that the mtx engine is initialized
    if( !m_IsMTXInitialized )
    {
      if( !MTX_Initialize_MTXEngine() )
      {
        m_IsMTXInitialized = false;
        StaticMatrixError( "Matrix", "Failed to initialize the MTX Engine. Try commenting out #define MTX_SIMD_OPTIMIZED in cmatrix.h" );
      }
      else
      {
        m_IsMTXInitialized = true;
      }
    }

    if( MTX_TimeMatch(
      &A.m_Matrix,
      timeColumnA,
      &B.m_Matrix,
      timeColumnB,
      precision,
      rolloverTime ) )
      return true;
    else 
      return false;
  }

  bool Matrix::Interpolate( 
    Matrix &A,                    //!< The matrix with interpolation times
    const unsigned timeColumnA,   //!< The zero based column index for matrix A
    Matrix &B,                    //!< The matrix to be interpolated
    const unsigned timeColumnB,   //!< The zero based column index for matrix B
    const double maxInterpolationInterval, //!< The largest interpolation interval allowed
    const double rolloverTime     //!< The rollover time, e.g. 60 s for minute based timing, 0.0 means rollovers not allowed
    )
  {
    // check that the mtx engine is initialized
    if( !m_IsMTXInitialized )
    {
      if( !MTX_Initialize_MTXEngine() )
      {
        m_IsMTXInitialized = false;
        StaticMatrixError( "Matrix", "Failed to initialize the MTX Engine. Try commenting out #define MTX_SIMD_OPTIMIZED in cmatrix.h" );
      }
      else
      {
        m_IsMTXInitialized = true;
      }
    }

    if( MTX_Interpolate(
      &A.m_Matrix,
      timeColumnA,
      &B.m_Matrix,
      timeColumnB,
      maxInterpolationInterval,
      rolloverTime ) )
      return true;
    else 
      return false;
  }



  // Return the column matrix specified by the column index. Returns (nrows x 1).
  Matrix  Matrix::Column(const unsigned col)
  {
    Matrix A;
    if( !MTX_CopyColumn( &m_Matrix, col, &A.m_Matrix ) )
    {

⌨️ 快捷键说明

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