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

📄 mmat_09.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 5 页
字号:
          this_a.m_d(this_a.index(row, col)) =	    (TIntegral)(m2_a.m_d(col)) *            (TIntegral)(m1_a.m_d(m1_a.index(col, row)));        }      }    }    // type2: FULL, SYMMETRIC, LOWER_TRIANGULAR, UPPER_TRIANGULAR    //  set the type of output matrix as full, and multiply elements in the    //  given row of the first matrix with the elements in the given column    //  of the second matrix.    //    else if ((type2 == Integral::FULL) ||	     (type2 == Integral::SYMMETRIC) ||	     (type2 == Integral::LOWER_TRIANGULAR) ||	     (type2 == Integral::UPPER_TRIANGULAR)) {      // create space in the output matrix      //      this_a.setDimensions(nrows, ncols, false, Integral::FULL);            // loop through over elements      //            for (long row = 0; row < nrows; row++) {        for (long col = 0; col < ncols; col++) {            this_a.m_d(this_a.index(row, col)) =             this_a.multiplyRowByColumn(m1_a, m2_a, row, col);        }      }          }    // type2: SPARSE    //  set the type of output matrix as full.     //    else if (type2 == Integral::SPARSE) {      // create space in the output matrix      //      this_a.setDimensions(nrows, ncols, false, Integral::FULL);      this_a.clear(Integral::RETAIN);             // declare local variables      //      long b_row;      long b_col;      TIntegral b_val;      TIntegral c_val = 0;      TIntegral sub_val = 0;      long length = m2_a.m_d.length();      // loop over the values of the sparse matrix and multiply      //      for (long b_index = 0; b_index < length; b_index++) {        b_row = m2_a.row_index_d(b_index);        b_col = m2_a.col_index_d(b_index);        b_val = m2_a.m_d(b_index);        // get the number of rows of the first operand	//        long a_rows = m1_a.getNumRows();                for (long a_index = 0; a_index < a_rows; a_index++) {          c_val = this_a.getValue(a_index, b_col);          sub_val = b_val * m1_a.getValue(a_index, b_row);          this_a.setValue(a_index, b_col, c_val + sub_val);        }      }    }  }  // type1: LOWER_TRIANGULAR  //  else if (type1 == Integral::LOWER_TRIANGULAR) {    // type2: DIAGONAL    //  set the type of output matrix as full.    //    if (type2 ==  Integral::DIAGONAL) {      // create space in the output matrix      //      this_a.setDimensions(m1_a, false, m1_a.type_d);            // loop over each element      //      for (long row = 0; row < nrows; row++) {        for (long col = 0; col <= row; col++) {          this_a.m_d(this_a.index(row, col)) =	    (TIntegral)(m2_a.m_d(col)) *            (TIntegral)(m1_a.m_d(m1_a.index(row, col)));        }      }    }    // type2: FULL, SYMMETRIC, LOWER_TRIANGULAR, UPPER_TRIANGULAR    //  set the type of output matrix as full, and multiply elements in the    //  given row of the first matrix with the elements in the given column    //  of the second matrix.    //    else if ((type2 == Integral::FULL) ||	     (type2 == Integral::SYMMETRIC) ||	     (type2 == Integral::LOWER_TRIANGULAR) ||      	     (type2 == Integral::UPPER_TRIANGULAR)) {      // create space in the output matrix      //      this_a.setDimensions(nrows, ncols, false, Integral::FULL);            // loop over all elements      //      for (long row = 0; row < nrows; row++) {        for (long col = 0; col < ncols; col++) {            this_a.m_d(this_a.index(row, col)) =             this_a.multiplyRowByColumn(m1_a, m2_a, row, col);        }      }          }    // type2: SPARSE    //  set the type of output matrix as full.    //    else if (type2 == Integral::SPARSE) {      // create space in the output matrix      //            this_a.setDimensions(nrows, ncols, false, Integral::FULL);      this_a.clear(Integral::RETAIN);             // declare local variables      //      long b_row;      long b_col;      TIntegral b_val;      TIntegral c_val = 0;      TIntegral sub_val = 0;      long length = m2_a.m_d.length();      // loop over the elements of sparse matrix, get the row index,      // column index and value of the element, then multiply it with      // corresponding element in the first matrix      //      for (long b_index = 0; b_index < length; b_index++) {        b_row = m2_a.row_index_d(b_index);        b_col = m2_a.col_index_d(b_index);        b_val = m2_a.m_d(b_index);        long a_rows = m1_a.getNumRows();        for (long a_index = 0; a_index < a_rows; a_index++) {          c_val = this_a.getValue(a_index, b_col);          sub_val = b_val * m1_a.getValue(a_index, b_row);          this_a.setValue(a_index, b_col, c_val + sub_val);        }      }    }      }  // type1: UPPER_TRIANGULAR  //  else if (type1 == Integral::UPPER_TRIANGULAR) {    // type2: DIAGONAL    //  set the type of output matrix as full.    //    if (type2 ==  Integral::DIAGONAL) {      // create space in the output matrix      //      this_a.setDimensions(m1_a, false, m1_a.type_d);            // loop over each element      //      for (long row = 0; row < nrows; row++) {        for (long col = row; col < nrows; col++) {          this_a.m_d(this_a.index(row, col)) =	    (TIntegral)(m2_a.m_d(col))*            (TIntegral)(m1_a.m_d(m1_a.index(row, col)));        }      }    }    // type2: FULL, SYMMETRIC, LOWER_TRIANGULAR, UPPER_TRIANGULAR    //  set the type of output matrix as full.    //    else if ((type2 == Integral::FULL) ||	     (type2 == Integral::SYMMETRIC) ||	     (type2 == Integral::LOWER_TRIANGULAR) ||      	     (type2 == Integral::UPPER_TRIANGULAR)) {      // create space in the output matrix      //      this_a.setDimensions(nrows, ncols, false, Integral::FULL);            // multiply elements in the given row of the first matrix with the      // elements in the given column of the second matrix      //      for (long row = 0; row < nrows; row++) {        for (long col = 0; col < ncols; col++) {            this_a.m_d(this_a.index(row, col)) =             this_a.multiplyRowByColumn(m1_a, m2_a, row, col);        }      }          }    // type2: SPARSE    //  set the type of output matrix as full.    //    else if (type2 == Integral::SPARSE) {      // create space in the output matrix      //            this_a.setDimensions(nrows, ncols, false, Integral::FULL);            // clear the contents of the current matrix      //      this_a.clear(Integral::RETAIN);             // declare local variables      //      long b_row;      long b_col;      TIntegral b_val;      TIntegral c_val = 0;      TIntegral sub_val = 0;      long length = m2_a.m_d.length();      // loop over the elements of sparse matrix, get the row index,      // column index and value of the element, then multiply it with      // corresponding element in the first matrix      //      for (long b_index = 0; b_index < length; b_index++) {        b_row = m2_a.row_index_d(b_index);        b_col = m2_a.col_index_d(b_index);        b_val = m2_a.m_d(b_index);        long a_rows = m1_a.getNumRows();        for (long a_index = 0; a_index < a_rows; a_index++) {          c_val = this_a.getValue(a_index, b_col);          sub_val = b_val * m1_a.getValue(a_index, b_row);          this_a.setValue(a_index, b_col, c_val + sub_val);        }      }    }      }  // type1: SPARSE  //  else if (type1 == Integral::SPARSE) {    // type2: DIAGONAL    //  set the type of output matrix as sparse    //    if (type2 == Integral::DIAGONAL) {      // create space in the output matrix      //            this_a.setDimensions(nrows, ncols, false, Integral::FULL);      this_a.clear(Integral::RETAIN);      // declare local variables      //      long row1 = 0;      long col1 = 0;      TIntegral val2 = 0;      TAIntegral val1 = 0;            // get the number of rows of the second matrix and the length of      // vector of sparse matrix      //      long len2 = m2_a.getNumRows();      long len1 = m1_a.m_d.length();      // loop over the number of rows of second matrix      //      for (long row2 = 0; row2 < len2; row2++) {        val2 = m2_a.m_d(row2);        for (long index = 0; index < len1; index++) {          row1 = m1_a.row_index_d(index);          col1 = m1_a.col_index_d(index);          val1 = m1_a.m_d(index);          // if the row index matches with position of diag vector          // elements, multiply them          //          if (row2 == col1) {            this_a.setValue(row1, row2, (TIntegral)val1 * val2);          }        }      }      // result should be sparse matrix      //      this_a.changeType(Integral::SPARSE);    }    // type2: FULL, SYMMETRIC, LOWER_TRIANGULAR, UPPER_TRIANGULAR    //  set the type of output matrix as full    //    else if ((type2 == Integral::FULL) ||	     (type2 == Integral::SYMMETRIC) ||	     (type2 == Integral::LOWER_TRIANGULAR) ||      	     (type2 == Integral::UPPER_TRIANGULAR)) {      // create space in the output matrix      //      this_a.setDimensions(nrows, ncols, false, Integral::FULL);      this_a.clear(Integral::RETAIN);             // declare local variables      //      long a_row;      long a_col;      TIntegral a_val;      TIntegral c_val = 0;      TIntegral sub_val = 0;      long length = m1_a.m_d.length();      // loop over the values of the sparse matrix      //      for (long a_index = 0; a_index < length; a_index++) {	// get the row index, column index and value	//        a_row = m1_a.row_index_d(a_index);        a_col = m1_a.col_index_d(a_index);        a_val = m1_a.m_d(a_index);	// rows of second matrix should be the same as the columns in	// the second matrix	//        long b_row = a_col;        long b_cols = m2_a.getNumColumns();        // loop over the columns of the second matrix	//        for (long b_index = 0; b_index < b_cols; b_index++) {          c_val = this_a.getValue(a_row, b_index);          sub_val = (TIntegral)a_val *	    (TIntegral)m2_a.getValue(b_row, b_index);          this_a.setValue(a_row, b_index, c_val + sub_val);        }      }    }    // type2: SPARSE    //  set the type of output matrix as sparse    //    else if (type2 == Integral::SPARSE) {      // temporary matrix is required      //      MMatrix<TScalar, TIntegral> temp(nrows, ncols);      temp.clear(Integral::RETAIN);      // temporary variables      //      long row;      long col;      TIntegral value;            // loop over elements of the first matrix      //      for (long i = 0; i < m1_a.m_d.length(); i++) {                // loop over elements of second matrix        //        for (long j = 0; j < m2_a.m_d.length(); j++) {                    // compare the respective column and row indices          //          if (m1_a.col_index_d(i) == m2_a.row_index_d(j)) {                        // multiply the elements and store them in a temporary matrix            //            row = m1_a.row_index_d(i);            col = m2_a.col_index_d(j);            value = temp.getValue(row, col) +              (TIntegral)m1_a.m_d(i) * (TIntegral)m2_a.m_d(j);            temp.setValue(row, col, value);          }        }      }      // copy the result to the current matrix      //      this_a.assign(temp, Integral::SPARSE);    }  }  // restore the type  //  return this_a.changeType(old_type);}// explicit instantiations//#ifndef ISIP_TEMPLATE_complextemplate booleanMMatrixMethods::mult<ISIP_TEMPLATE_TARGET, Byte, byte>(MMatrix<ISIP_TEMPLATE_TARGET>&, const MMatrix<ISIP_TEMPLATE_TARGET>&, const MMatrix<Byte, byte>&);template booleanMMatrixMethods::mult<ISIP_TEMPLATE_TARGET, Ushort, ushort>(MMatrix<ISIP_TEMPLATE_TARGET>&, const MMatrix<ISIP_TEMPLATE_TARGET>&, const MMatrix<Ushort, ushort>&);template booleanMMatrixMethods::mult<ISIP_TEMPLATE_TARGET, Ulong, ulong>(MMatrix<ISIP_TEMPLATE_TARGET>&, const MMatrix<ISIP_TEMPLATE_TARGET>&, const MMatrix<Ulong, ulong>&);template booleanMMatrixMethods::mult<ISIP_TEMPLATE_TARGET, Ullong, ullong>(MMatrix<ISIP_TEMPLATE_TARGET>&, const

⌨️ 快捷键说明

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