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

📄 mmat_02.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 5 页
字号:
	tmp_mat.assign(arg_mat1);	tmp_mat.swap(res_mat);		if (!res_mat.almostEqual(arg_mat1)) {	  Console::put(arg1_str);	  Error::handle(name(), L"swap", Error::TEST, __FILE__, __LINE__);	}		// test getType	//	if (arg_mat1.getType() != (Integral::MTYPE)type1) {	  Console::put(arg1_str);	  Error::handle(name(), L"getType", Error::TEST, __FILE__, __LINE__);	}		// test nextZero - note that calling this method for negative one	// row and column indices returns the positions of first zero	// elements of the matrix	//	tmp_mat.assign(arg_mat1);	long row_index = -1;	long col_index = -1;		tmp_mat.nextZero(row_index, col_index,			 (long)MMAT_NEXT_ZERO_ARG[0],			 (long)MMAT_NEXT_ZERO_ARG[1]);	if ((row_index != (long)MMAT_NEXT_ZERO_RES[mat1 * 2]) ||	    (col_index != (long)MMAT_NEXT_ZERO_RES[mat1 * 2 + 1])) {	  Console::put(arg1_str);	  Error::handle(name(), L"nextZero", Error::TEST, __FILE__, __LINE__);	}		// test nextNonZero - note that calling this method for negative one	// row and column indices returns the positions of first non-zero	// elements of the matrix	//      	TIntegral tmp_val;	tmp_mat.nextNonZero(tmp_val, row_index, col_index,			    (long)MMAT_NEXT_NONZERO_ARG[0],			    (long)MMAT_NEXT_NONZERO_ARG[1]);#ifdef ISIP_TEMPLATE_complex		complexdouble tmp_complex6(MMAT_NEXT_NONZERO_RES[mat1 * 4],				  MMAT_NEXT_NONZERO_RES[mat1 * 4 + 3]);#endif		if ((row_index != (long)MMAT_NEXT_NONZERO_RES[mat1 * 4 + 1]) ||	    (col_index != (long)MMAT_NEXT_NONZERO_RES[mat1 * 4 + 2]) ||#ifndef ISIP_TEMPLATE_complex	    (!(TScalar(tmp_val)).almostEqual(			   (TIntegral)MMAT_NEXT_NONZERO_RES[mat1 * 4]))) {#else	  (!(TScalar(tmp_val)).almostEqual((TIntegral)tmp_complex6))) {#endif	  Console::put(arg1_str);	  Error::handle(name(), L"nextNonZero", Error::TEST, __FILE__, __LINE__);	}	// test dimensions and capacity:	//	res_mat.setDimensions(0, 0, false, Integral::FULL);	tmp_mat.assign(arg_mat1);		// set the dimension to zero	//	tmp_mat.setDimensions(0, 0, false);		if (((long)(tmp_mat.m_d.length()) != 0) ||	    ((long)(tmp_mat.row_index_d.length()) != 0) ||	    ((long)(tmp_mat.col_index_d.length()) != 0) ||	    ((long)(tmp_mat.nrows_d) != 0) ||	    ((long)tmp_mat.ncols_d != 0)) {	  Console::put(arg1_str);		  Error::handle(name(), L"setCapacity", Error::TEST, 			       __FILE__, __LINE__);	}		// set the dimensions	//	tmp_mat.assign(arg_mat1);	tmp_mat.setDimensions(3, 3);	#ifndef ISIP_TEMPLATE_complex	res_mat.assign((long)MMAT_SET_DIM_RES[mat1][MMAT_NROW_LOC], 		       (long)MMAT_SET_DIM_RES[mat1][MMAT_NCOL_LOC], 		       (double*)&MMAT_SET_DIM_RES[mat1][MMAT_DATA_LOC]);#else	res_mat.assignComplexDiagnose((long)MMAT_SET_DIM_RES[mat1][MMAT_NROW_LOC], 		       (long)MMAT_SET_DIM_RES[mat1][MMAT_NCOL_LOC], 		       (double*)&MMAT_SET_DIM_RES[mat1][MMAT_DATA_LOC]);#endif			if (!res_mat.eq(tmp_mat)) {	  Console::put(arg1_str);	  tmp_mat.debug(L"SET_DIM_RES");	  res_mat.debug(L"res_mat");	  Error::handle(name(), L"setDimensions", Error::TEST, __FILE__, 			__LINE__);	}	// set the capacity	//	tmp_mat.assign(arg_mat1);	tmp_mat.setCapacity(5, 5);	if (!tmp_mat.eq(arg_mat1)) {	  tmp_mat.debug(L"tmp_mat");	  arg_mat1.debug(L"arg_mat");	  Console::put(arg1_str);	  Error::handle(name(), L"setCapacity", Error::TEST, __FILE__, 			__LINE__);	}		// test special case of eq:	//  make sure the zero elements are tested for equality.	//	tmp_mat.makeDiagonal((TIntegral)MMAT_MAKEDIAG_SCAL, 4,			     (Integral::MTYPE)type1);		if (tmp_mat.eq((TIntegral)MMAT_MAKEDIAG_SCAL)) {	  return Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);	}	// test special case of lt:	//  should return false for triangular matrices when all the	//  elements in lower or upper triangular part of the matrix are	//  negative	//	tmp_mat.clear(Integral::RETAIN);		// create lower triangular matrix for test	//	if (arg_mat1.isSquare()) {	  if ((type1 != Integral::UPPER_TRIANGULAR) &&	      ((mat1 % MMAT_NUM_MATS_REAL) != 4)) {  	    tmp_mat.setDimensions(4, 4, false,				  Integral::LOWER_TRIANGULAR);	    tmp_mat.setLower(arg_mat1);	    tmp_mat.m_d.abs();	    tmp_mat.neg();	    	    if (tmp_mat.isTypePossible((Integral::MTYPE)type1)) {	      tmp_mat.changeType((Integral::MTYPE)type1);	      	      if (tmp_mat.lt(0)) {		Console::put(arg1_str);		return Error::handle(name(), L"lt", Error::TEST,				     __FILE__, __LINE__);	      }	    }	  }	  	  // create an upper triangular matrix for test	  //	  if ((type1 != Integral::LOWER_TRIANGULAR) &&	      ((mat1 % MMAT_NUM_MATS_REAL) != 3)) {	    tmp_mat.clear(Integral::RETAIN);	    tmp_mat.setDimensions(4, 4, false,				  Integral::UPPER_TRIANGULAR);	    tmp_mat.setUpper(arg_mat1);	    tmp_mat.m_d.abs();      	    tmp_mat.neg();	    	    if (tmp_mat.isTypePossible((Integral::MTYPE)type1)) {	      tmp_mat.changeType((Integral::MTYPE)type1);	      	      if (tmp_mat.lt(0)) {		Console::put(arg1_str);		return Error::handle(name(), L"lt", Error::TEST,				     __FILE__, __LINE__);	      }	    }	  }  	  // test special case of gt:	  //  should return false for triangular matrices when all the	  //  elements in lower or upper triangular part of the matrix are	  //  positive	  //	  if ((type1 != Integral::UPPER_TRIANGULAR) &&	      ((mat1 % MMAT_NUM_MATS_REAL) != 4)) {	    tmp_mat.clear(Integral::RETAIN);	    tmp_mat.setDimensions(4, 4, false,				  Integral::LOWER_TRIANGULAR);	    tmp_mat.setLower(arg_mat1);	    tmp_mat.m_d.abs();	    	    if (tmp_mat.isTypePossible((Integral::MTYPE)type1)) {	      tmp_mat.changeType((Integral::MTYPE)type1);	      if (tmp_mat.gt(0)) {		Console::put(arg1_str);		return Error::handle(name(), L"gt", Error::TEST,				     __FILE__, __LINE__);	      }	    }	  }	  // create an upper triangular for test	  //	  if ((type1 != Integral::LOWER_TRIANGULAR) &&	      ((mat1 % MMAT_NUM_MATS_REAL) != 3)) {      	    tmp_mat.clear(Integral::RETAIN);	    tmp_mat.setDimensions(4, 4, false,				  Integral::UPPER_TRIANGULAR);	    tmp_mat.setUpper(arg_mat1);	    tmp_mat.m_d.abs();      	    	    if (tmp_mat.isTypePossible((Integral::MTYPE)type1)) {	      tmp_mat.changeType((Integral::MTYPE)type1);	      if (tmp_mat.gt(0)) {		Console::put(arg1_str);		return Error::handle(name(), L"gt", Error::TEST,				     __FILE__, __LINE__);	      }	    }	  }	}	// test relational operators:	//  test numEqual with two keys	//	if (arg_mat1.numEqual((long)MMAT_NUM_EQUAL_VAL0)	    != MMAT_NUM_EQUAL_RES0[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"numEqual", Error::TEST,			__FILE__, __LINE__);	}	if (arg_mat1.numEqual((long)MMAT_NUM_EQUAL_VAL1)	    != MMAT_NUM_EQUAL_RES1[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"numEqual", Error::TEST,			__FILE__, __LINE__);	}#ifdef ISIP_TEMPLATE_complex	if (arg_mat1.numEqual((complexlong)MMAT_NUM_EQUAL_VAL2)	    != MMAT_NUM_EQUAL_RES2[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"numEqual", Error::TEST,			__FILE__, __LINE__);	}	if (arg_mat1.numEqual((complexlong)MMAT_NUM_EQUAL_VAL3)	    != MMAT_NUM_EQUAL_RES3[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"numEqual", Error::TEST,			__FILE__, __LINE__);	}#endif		// test numNotEqual with two keys	//	if (arg_mat1.numNotEqual((long)MMAT_NUM_NOT_EQUAL_VAL0)	    != MMAT_NUM_NOT_EQUAL_RES0[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"numNotEqual", Error::TEST,			__FILE__, __LINE__);	}	if (arg_mat1.numNotEqual((long)MMAT_NUM_NOT_EQUAL_VAL1)	    != MMAT_NUM_NOT_EQUAL_RES1[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"numNotEqual", Error::TEST,			__FILE__, __LINE__);	}#ifdef ISIP_TEMPLATE_complex	if (arg_mat1.numNotEqual((complexlong)MMAT_NUM_NOT_EQUAL_VAL2)	    != MMAT_NUM_NOT_EQUAL_RES2[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"numNotEqual", Error::TEST,			__FILE__, __LINE__);	}	if (arg_mat1.numNotEqual((complexlong)MMAT_NUM_NOT_EQUAL_VAL3)	    != MMAT_NUM_NOT_EQUAL_RES3[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"numNotEqual", Error::TEST,			__FILE__, __LINE__);	}#endif		// test gt	//	if (arg_mat1.gt((TIntegral)MMAT_GT_VAL0) != MMAT_GT_RES0[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"gt", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.gt((TIntegral)MMAT_GT_VAL1) != MMAT_GT_RES1[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"gt", Error::TEST, __FILE__, __LINE__);	}#ifdef ISIP_TEMPLATE_complex	if (arg_mat1.gt((complexdouble)MMAT_GT_VAL2) != MMAT_GT_RES2[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"gt", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.gt((TIntegral)MMAT_GT_VAL1) != MMAT_GT_RES1[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"gt", Error::TEST, __FILE__, __LINE__);	}#endif	// test ge	//	if (arg_mat1.ge((TIntegral)MMAT_GE_VAL0) != MMAT_GE_RES0[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"ge", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.ge((TIntegral)MMAT_GE_VAL1) != MMAT_GE_RES1[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"ge", Error::TEST, __FILE__, __LINE__);	}#ifdef ISIP_TEMPLATE_complex	if (arg_mat1.ge((TIntegral)MMAT_GE_VAL2) != MMAT_GE_RES2[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"ge", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.ge((TIntegral)MMAT_GE_VAL3) != MMAT_GE_RES3[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"ge", Error::TEST, __FILE__, __LINE__);	}#endif		// test lt	//	if (arg_mat1.lt((TIntegral)MMAT_LT_VAL0) != MMAT_LT_RES0[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"lt", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.lt((TIntegral)MMAT_LT_VAL1) != MMAT_LT_RES1[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"lt", Error::TEST, __FILE__, __LINE__);	}#ifdef ISIP_TEMPLATE_complex	if (arg_mat1.lt((TIntegral)MMAT_LT_VAL2) != MMAT_LT_RES2[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"lt", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.lt((TIntegral)MMAT_LT_VAL3) != MMAT_LT_RES3[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"lt", Error::TEST, __FILE__, __LINE__);	}#endif			// test le	//	if (arg_mat1.le((TIntegral)MMAT_LE_VAL0) != MMAT_LE_RES0[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"le", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.le((TIntegral)MMAT_LE_VAL1) != MMAT_LE_RES1[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"le", Error::TEST, __FILE__, __LINE__);	}#ifdef ISIP_TEMPLATE_complex	if (arg_mat1.le((TIntegral)MMAT_LE_VAL2) != MMAT_LE_RES2[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"le", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.le((TIntegral)MMAT_LE_VAL3) != MMAT_LE_RES3[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"le", Error::TEST, __FILE__, __LINE__);	}#endif			// test eq	//	if (arg_mat1.eq((TIntegral)MMAT_EQ_VAL0) != MMAT_EQ_RES0[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.eq((TIntegral)MMAT_EQ_VAL1) != MMAT_EQ_RES1[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);	}#ifdef ISIP_TEMPLATE_complex	if (arg_mat1.eq((TIntegral)MMAT_EQ_VAL2) != MMAT_EQ_RES2[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.eq((TIntegral)MMAT_EQ_VAL3) != MMAT_EQ_RES3[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"eq", Error::TEST, __FILE__, __LINE__);	}#endif			// test ne	//	if (arg_mat1.ne((TIntegral)MMAT_NE_VAL0) != MMAT_NE_RES0[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.ne((TIntegral)MMAT_NE_VAL1) != MMAT_NE_RES1[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);	}#ifdef ISIP_TEMPLATE_complex	if (arg_mat1.ne((TIntegral)MMAT_NE_VAL2) != MMAT_NE_RES2[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);	}	if (arg_mat1.ne((TIntegral)MMAT_NE_VAL3) != MMAT_NE_RES3[mat1]) {	  Console::put(arg1_str);	  Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);	}#endif			tmp_mat.assign(arg_mat1);	if (arg_mat1.ne(arg_mat1)) {	  Console::put(arg1_str);	  Error::handle(name(), L"ne", Error::TEST, __FILE__, __LINE__);	}	// test min and max methods	//	long row_pos;	long col_pos;	TIntegral val;	TScalar val_res;	// test min	//	val = arg_mat1.min(row_pos, col_pos);#ifndef ISIP_TEMPLATE_complex	val_res.assign((TIntegral)MMAT_MIN_RES[mat1][MMAT_DATA_LOC]);#else	complexdouble tmp_complex2(MMAT_MIN_RES[mat1][MMAT_DATA_LOC],				  MMAT_MIN_RES[mat1][MMAT_DATA_LOC + 1]);	val_res.assign((TIntegral)tmp_complex2);#endif	if ((!val_res.almostEqual(val)) ||	    (row_pos != (long)MMAT_MIN_RES[mat1][MMAT_NROW_LOC]) ||	    (col_pos != (long)MMAT_MIN_RES[mat1][MMAT_NCOL_LOC])) {	  Console::put(arg1_str);	  Error::handle(name(), L"min", Error::TEST, __FILE__, __LINE__);

⌨️ 快捷键说明

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