MatrixFloat MatrixFloat::multiple(const MatrixFloat &b) const{ const unsigned int M = rows; const unsigned int N = cols; const unsigned int K = b.getNumRows(); const unsigned int L = b.getNumCols(); if( N != K ) { errorLog << "multiple(MatrixFloat b) - The number of rows in b (" << K << ") does not match the number of columns in this matrix (" << N << ")" << std::endl; return MatrixFloat(); } MatrixFloat c(M,L); Float **pb = b.getDataPointer(); Float **pc = c.getDataPointer(); unsigned int i,j,k = 0; for(i=0; i<M; i++){ for(j=0; j<L; j++){ pc[i][j] = 0; for(k=0; k<K; k++){ pc[i][j] += dataPtr[i*cols+k] * pb[k][j]; } } } return c; }
MatrixFloat TimeSeriesClassificationData::getSampleData(UINT classLabel, UINT recordID) const { int record = 0; for(UINT x=0; x<totalNumSamples; x++){ if( data[x].getClassLabel() == classLabel ){ if(record == recordID) { return data[x].getData(); } else record++; } } return MatrixFloat(); }
MatrixFloat MatrixFloat::multiple(const Float value) const{ if( dataPtr == NULL ) return MatrixFloat(); MatrixFloat d(rows,cols); Float *d_p = &(d[0][0]); unsigned int i = 0; for(i=0; i<rows*cols; i++){ d_p[i] = dataPtr[i] * value; } return d; }
MatrixFloat ClassificationDataStream::getTimeSeriesData( const TimeSeriesPositionTracker &trackerInfo ) const { if( trackerInfo.getStartIndex() >= totalNumSamples || trackerInfo.getEndIndex() > totalNumSamples ){ warningLog << "getTimeSeriesData(TimeSeriesPositionTracker trackerInfo) - Invalid tracker indexs!" << std::endl; return MatrixFloat(); } UINT startIndex = trackerInfo.getStartIndex(); UINT endIndex = trackerInfo.getEndIndex(); UINT M = endIndex > 0 ? trackerInfo.getLength() : totalNumSamples - startIndex; UINT N = getNumDimensions(); MatrixFloat tsData(M,N); for(UINT i=0; i<M; i++){ for(UINT j=0; j<N; j++){ tsData[i][j] = data[ i+startIndex ][j]; } } return tsData; }
MatrixFloat TimeSeriesClassificationData::getDataAsMatrixFloat() const { //Count how many samples are in the entire dataset UINT M = 0; UINT index = 0; for(UINT x=0; x<totalNumSamples; x++){ M += data[x].getLength(); } if( M == 0 ) MatrixFloat(); //Get all the data and concatenate it into 1 matrix MatrixFloat matrixData(M,numDimensions); for(UINT x=0; x<totalNumSamples; x++){ for(UINT i=0; i<data[x].getLength(); i++){ for(UINT j=0; j<numDimensions; j++){ matrixData[index][j] = data[x][i][j]; } index++; } } return matrixData; }