📄 tr_st_read_0.cc
字号:
// file: tr_st_read_0.cc//// isip include files//#include "train_state.h"#include "train_state_constants.h" // method: read_data_cc//// arguments:// FILE* fp : (input) the file pointer to read data from//// return: a logical_1 indicating success//// this method reads all the parameters for this state from file//logical_1 Train_State::read_data_cc(FILE* fp_a) { // make sure the file is valid // if (fp_a == (FILE*)NULL) { error_handler_cc((char_1*)"read_data_cc", (char_1*)"File pointer is NULL"); } // read the number of mixtures in the state // fread((void_p)&num_mixtures_d, sizeof(int_4), 1, fp_a); // declare memory for the mean, covar, scale and weights for this state // if (num_mixtures_d > (int_4)0) { weights_d = new float_4[num_mixtures_d]; scale_d = new float_4[num_mixtures_d]; mean_d = new float_4*[num_mixtures_d]; covar_d = new float_4*[num_mixtures_d]; // loop over all mixtures and read data // for (int_4 j = 0; j < num_mixtures_d; j++) { // read the mixture weight // fread((void_p)&weights_d[j], sizeof(float_4), 1, fp_a); weights_d[j] = (float_4)log((float_8)weights_d[j]); // read the mean // mean_d[j] = new float_4[num_features_d]; for (int_4 k = 0; k < num_features_d; k++) { fread((void_p)&mean_d[j][k], sizeof(float_4), 1, fp_a); } // read the covar and save as inverse // covar_d[j] = new float_4[num_features_d]; for (int_4 k = 0; k < num_features_d; k++) { fread((void_p)&covar_d[j][k], sizeof(float_4), 1, fp_a); covar_d[j][k] = (float_4)1 / covar_d[j][k]; } // read in the scale factor // fread((void_p)&scale_d[j], sizeof(float_4), 1, fp_a); } } // end if num_mixtures_d > 0 // exit gracefully // return ISIP_TRUE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -