55 assert( col_minmax.size() == data.
cols() );
58 #pragma omp parallel for
59 for(
size_t r = 0; r < data.
rows(); ++r ) {
60 for(
size_t c = 0; c < data.
cols(); ++c ) {
62 assert( col_minmax[c].max >= col_minmax[c].min );
63 double diff = col_minmax[c].max - col_minmax[c].min;
64 data( r, c ) = ( data( r, c ) - col_minmax[c].min ) / diff;
74 assert( row_minmax.size() == data.
rows() );
77 #pragma omp parallel for
78 for(
size_t r = 0; r < data.
rows(); ++r ) {
79 for(
size_t c = 0; c < data.
cols(); ++c ) {
81 assert( row_minmax[r].max >= row_minmax[r].min );
82 double diff = row_minmax[r].max - row_minmax[r].min;
83 data( r, c ) = ( data( r, c ) - row_minmax[r].min ) / diff;
99 auto col_mean_stddev = std::vector<MeanStddevPair>( data.
cols() );
102 #pragma omp parallel for
103 for(
size_t c = 0; c < data.
cols(); ++c ) {
104 col_mean_stddev[c] =
mean_stddev( data.
col(c).begin(), data.
col(c).end(), 0.0000001 );
106 for(
size_t r = 0; r < data.
rows(); ++r ) {
110 data( r, c ) -= col_mean_stddev[c].mean;
115 assert( col_mean_stddev[c].stddev > 0.0 );
116 data( r, c ) /= col_mean_stddev[c].stddev;
121 return col_mean_stddev;
129 auto row_mean_stddev = std::vector<MeanStddevPair>( data.
rows() );
132 #pragma omp parallel for
133 for(
size_t r = 0; r < data.
rows(); ++r ) {
134 row_mean_stddev[r] =
mean_stddev( data.
row(r).begin(), data.
row(r).end(), 0.0000001 );
136 for(
size_t c = 0; c < data.
cols(); ++c ) {
140 data( r, c ) -= row_mean_stddev[r].mean;
145 assert( row_mean_stddev[r].stddev > 0.0 );
146 data( r, c ) /= row_mean_stddev[r].stddev;
151 return row_mean_stddev;
164 std::vector<size_t> keep_cols;
165 for(
size_t c = 0; c < data.
cols(); ++c ) {
167 if( ! std::isfinite( col_minmax[c].min ) || ! std::isfinite( col_minmax[c].max )) {
171 assert( col_minmax[c].min <= col_minmax[c].max );
172 if (( col_minmax[c].max - col_minmax[c].min ) > epsilon ) {
173 keep_cols.push_back( c );
176 assert( keep_cols.size() <= data.
cols() );
181 #pragma omp parallel for
182 for(
size_t r = 0; r < data.
rows(); ++r ) {
183 for(
size_t i = 0; i < keep_cols.size(); ++i ) {
184 new_mat( r, i ) = data( r, keep_cols[i] );
205 for(
auto& elem : sscp ) {
206 elem /=
static_cast<double>( data.
rows() );
219 for(
auto& elem : sscp ) {
220 elem /=
static_cast<double>( data.
rows() );
230 for(
size_t c1 = 0; c1 < data.
cols(); ++c1 ) {
231 for(
size_t c2 = c1; c2 < data.
cols(); ++c2 ) {
233 for(
size_t r = 0; r < data.
rows(); ++r ) {
234 mat( c1, c2 ) += data( r, c1 ) * data( r, c2 );
236 mat( c2, c1 ) = mat( c1, c2 );