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

📄 mmat_10.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
    }    // set the appropriate length: this is calculated using the current index    // index and the number of remaining elements    //    num_elements = index + num_remain;    this_a.m_d.setLength(num_elements);    this_a.row_index_d.setLength(num_elements);    this_a.col_index_d.setLength(num_elements);  }  // exit gracefully  //  return true;}// explicit instantiations//template booleanMMatrixMethods::setRow<ISIP_TEMPLATE_TARGET>(MMatrix<ISIP_TEMPLATE_TARGET>&, long, const MVector<ISIP_TEMPLATE_TARGET>&); // method: setColumn//// arguments://  MMatrix<TScalar, TIntegral>& this: (output) class operand//  long col_index: (input) column index for the column which needs to be set//  const MVector<TScalar, TIntegral>& vector: (input) a row vector//// return: a boolean value indicating status//template<class TScalar, class TIntegral>booleanMMatrixMethods::setColumn(MMatrix<TScalar, TIntegral>& this_a, 			  long col_index_a,			  const MVector<TScalar, TIntegral>& vector_a) {   // check the argument  //  if ((col_index_a < 0) || (col_index_a >= this_a.ncols_d) ||      (this_a.nrows_d != vector_a.length())) {        this_a.debug(L"this_a");    vector_a.debug(L"vector_a");        return Error::handle(name(), L"setColumn", Error::ARG, __FILE__, __LINE__);  }  // since most of our matrices are stored in a row-major format, the  // easiest way to do this is to simply loop over the elements and  // copy them one by one  //  for (long row = 0; row < this_a.nrows_d; row++) {    this_a.setValue(row, col_index_a, vector_a(row));  }  // exit gracefully  //  return true;}// explicit instantiations//template booleanMMatrixMethods::setColumn<ISIP_TEMPLATE_TARGET>(MMatrix<ISIP_TEMPLATE_TARGET>&, long, const MVector<ISIP_TEMPLATE_TARGET>&); // method: findRow//// arguments://  const MMatrix<TScalar, TIntegral>& this: (output) class operand//  const MVector<TScalar, TIntegral>& v: (input) vector to be matched//// return: long value containing the row index for the input row vector//// this method returns only the position of the first exact match of// the specified row in the matrix//template<class TScalar, class TIntegral>long MMatrixMethods::findRow(const MMatrix<TScalar, TIntegral>& this_a, 			     const MVector<TScalar, TIntegral>& v_a) {    // declare local variables  //  long pos;  // get the number of rows of the current matrix  //  long last_pos = this_a.getNumRows();  // declare a temporary vector  //  MVector<TScalar, TIntegral> vector;  // check all row vectors in the matrix for exact match  //   for (pos = 0; pos < last_pos; pos++) {    this_a.getRow(vector, pos);    if (v_a.eq(vector)) {      return pos;    }  }  // if no match found, then return -1  //  pos = -1;  // return the value  //  return pos;}// explicit instantiations//template longMMatrixMethods::findRow<ISIP_TEMPLATE_TARGET>(const MMatrix<ISIP_TEMPLATE_TARGET>&, const MVector<ISIP_TEMPLATE_TARGET>&); // method: nextZero//// arguments://  const MMatrix<TScalar, TIntegral>& this: (input) class operand//  long& row_index: (output) row index for the next zero value//  long& col_index: (output) column index for the next zero value//  long  row_start: (input) start row//  long  col_start: (input) start column //// return: a boolean value indicating status//// this method returns position of next zero element in the matrix, it// starts searching the matrix from the specified row and column index//template<class TScalar, class TIntegral>boolean MMatrixMethods::nextZero(const MMatrix<TScalar, TIntegral>& this_a,				 long& row_index_a, long& col_index_a,				 long row_start_a, long col_start_a) {      // declare local variables  //  long row_start;  long col_start;    // get dimensions of the input matrix  //  long nrows = this_a.getNumRows();  long ncols = this_a.getNumColumns();    // check the arguments  //  if ((col_start_a >= ncols) || (row_start_a < -1)) {    this_a.debug(L"this_a");        return Error::handle(name(), L"nextZero", Error::ARG,			 __FILE__, __LINE__);  }    // calculate start row and column index:  //  if starting row index is negative, set the start row and column  //  index to zero  //  if (row_start_a == -1) {    row_start = 0;    col_start = 0;  }  else {    // find the next column number    //    col_start = col_start_a + 1;    row_start = row_start_a;    // if reaching the end of row, begin from the next row    //    if (col_start >= ncols) {      col_start = 0;      row_start++;    }  }    // if row_start is out of range, there is no other zero in the matrix  //  if (row_start >= nrows) {        // exit ungracefully    //    return false;  }    // search the starting row for zero value  //  for (long j = col_start; j < ncols; j++) {        // if the element is zero    //    if (this_a.getValue(row_start, j) == 0) {            // record the position      //      row_index_a = row_start;      col_index_a = j;            // exit gracefully      //      return true;    }  }    // check the following rows for zero element  //  for (long i = row_start + 1; i < nrows; i++) {    for (long j = 0; j < ncols; j++) {            // if the element is zero      //      if (this_a.getValue(i, j) == 0) {		// record the position	//	row_index_a = i;	col_index_a = j;		// exit gracefully	//	return true;      }    }  }    // no other zero can be found on the matrix  //  return false;}// explicit instantiations//template booleanMMatrixMethods::nextZero<ISIP_TEMPLATE_TARGET>(const MMatrix<ISIP_TEMPLATE_TARGET>&, long&, long&, long, long);// method: nextNonZero//// arguments://  const MMatrix<TScalar, TIntegral>& this: (input) class operand//  TIntegral& value: (output) returned non zero value//  long& row_index: (output) row index for the next non-zero value//  long& col_index: (output) column index for the next non-zero value//  long row_start: (input) start row//  long col_start: (input) start column//// return: a boolean value indicating status//// this method returns position of next non-zero element in the matrix, it// starts searching the matrix from the specified row and column index//template<class TScalar, class TIntegral>boolean MMatrixMethods::nextNonZero(const MMatrix<TScalar, TIntegral>& this_a,				    TIntegral& value_a,				    long& row_index_a, long& col_index_a,				    long row_start_a, long col_start_a) {    // declare local variables  //  long row_start;  long col_start;  // get dimensions of input matrix  //  long nrows = this_a.getNumRows();  long ncols = this_a.getNumColumns();  // check the arguments  //  if (col_start_a >= ncols) {    this_a.debug(L"this_a");        return Error::handle(name(), L"nextNonZero", Error::ARG,			 __FILE__, __LINE__);  }  // calculate the start position  //  if (row_start_a < 0) {    row_start = 0;    col_start = 0;  }  else {    // find the next column number    //    col_start = col_start_a + 1;    row_start = row_start_a;    // if reaching the end of row, begin from the next row    //    if (col_start >= ncols) {      col_start = 0;      row_start++;    }  }  // if row_start is out of range, there is no other non-zero element  // on the matrix  //  if (row_start >= nrows) {    // exit gracefully    //    return false;  }  // type: DIAGONAL  //  only search the diagonal elements, as off-diagonal elements are all zeros  //  if (this_a.type_d == Integral::DIAGONAL) {    // adjust start row    //    if (row_start < col_start) {      row_start++;    }        // search through the diagonal elements    //    for (long i = row_start; i < nrows; i++) {      // search for non-zero element on the diagonal      //      if ((TIntegral)(this_a.m_d(i)) != 0) {	// record the position and value	//	row_index_a = i;	col_index_a = i;	value_a = this_a.m_d(i);	// exit gracefully	//	return true;      }    }  }  // type: FULL, SYMMETRIC  //  loop through each element from the start position to find the first  //  non-zero element  //  else if ((this_a.type_d == Integral::FULL) ||	   (this_a.type_d == Integral::SYMMETRIC)) {        // search through the elements    //    for (long i = row_start; i < nrows; i++) {      for (long j = col_start; j < ncols; j++) {	// search for non-zero element in the matrix	//	if (this_a.getValue(i, j) != 0) {	  // record the position and value	  //	  row_index_a = i;	  col_index_a = j;	  value_a = this_a.getValue(i, j);	  // exit gracefully	  //	  return true;	}      }      // reset the col_start to zero      //      col_start = 0;    }  }  // type: LOWER_TRIANGULAR, UPPER_TRIANGULAR  //  search lower triangular or upper triangular part, which is implemented  //  by calling of stopColumn and startColumn methods.  //  else if ((this_a.type_d == Integral::LOWER_TRIANGULAR) ||	   (this_a.type_d == Integral::UPPER_TRIANGULAR)) {        // search through the elements    //    for (long i = row_start; i < nrows; i++) {      // get the stop column index in the current row:      //  for lower triangular, it will be the current row's index;      //  for upper triangular, it will be the maximum column index;      //      long stop_col = this_a.stopColumn(i, this_a.type_d);       // loop over the columns from start column to the stop column      //      for (long j = col_start; j <= stop_col; j++) {	// search for non-zero element	//	if (this_a.getValue(i, j) != 0) {	  // record the position and value	  //	  row_index_a = i;	  col_index_a = j;	  value_a = (this_a.m_d(this_a.index(i, j)));	  // exit gracefully	  //	  return true;	}      }      // reset the col_start to zero      //      col_start = 0;    }  }  // type: SPARSE  //  search through each element, and find the first element whose position  //  is greater than the start position, as the value of this element is  //  sure to be non-zero for sparse matrix.  //  else if (this_a.type_d == Integral::SPARSE) {    // get the length of the storage vector, which gives the number of    // non-zero elements in the matrix    //    long value_len = this_a.m_d.length();    // loop over the vector and find the element    //    for (long i = 0; i < value_len; i++) {      if ((row_start < this_a.row_index_d(i)) ||	  ((row_start == this_a.row_index_d(i)) &&	   (col_start <= this_a.col_index_d(i)))) {	  // record the position and value	  //	  row_index_a = this_a.row_index_d(i);	  col_index_a = this_a.col_index_d(i);	  value_a = this_a.m_d(i);	  // exit gracefully	  //	  return true;      }    }  }  // only zeros are left in the matrix  //  return false;}// explicit instantiations//template booleanMMatrixMethods::nextNonZero<ISIP_TEMPLATE_TARGET>(const MMatrix<ISIP_TEMPLATE_TARGET>&, ISIP_TEMPLATE_T1&, long&, long&, long, long);

⌨️ 快捷键说明

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