Skip to content

Commit

Permalink
dih shifts with correlated data. test it!
Browse files Browse the repository at this point in the history
  • Loading branch information
lettis committed Jan 7, 2016
1 parent 3aa947d commit ccaff4e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/file_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,31 +142,42 @@ namespace FastPCA {
dih_shifts = FastPCA::Periodic::dih_shifts(file_in, mem_buf_size);
if (use_correlation) {
for (std::size_t i=0; i < dih_shifts.size(); ++i) {
//TODO: check signs
dih_shifts[i] = (means[i] - dih_shifts[i]) * sigmas[i];
dih_shifts[i] = (dih_shifts[i] - means[i]) * sigmas[i];
}
}
}
// projections

//TODO debug
//DataFileWriter<double> fh_orig("dih_orig");
//DataFileWriter<double> fh_orig_scaled("dih_orig_scaled");
//DataFileWriter<double> fh_cov_shift("dih_cov_shift");
//DataFileWriter<double> fh_corr_shift("dih_corr_shift");
//DataFileWriter<double> fh_mean_shift("dih_mean_shift");

bool append_to_file = false;
DataFileReader<double> fh_file_in(file_in, mem_buf_size);
DataFileWriter<double> fh_file_out(file_out);
read_blockwise(fh_file_in, [&](Matrix<double>& m) {
// convert degrees to radians
FastPCA::deg2rad_inplace(m);
//fh_orig.write(m, append_to_file);
if (use_correlation || (! use_dih_shifts)) {
// shift by periodic means
FastPCA::Periodic::shift_matrix_columns_inplace(m, means);
//fh_mean_shift.write(m, append_to_file);
} else if (use_dih_shifts) {
// shift by optimal dih-shifts
FastPCA::Periodic::shift_matrix_columns_inplace(m, dih_shifts);
//fh_cov_shift.write(m, append_to_file);
}
if (use_correlation) {
// scale data by sigmas for correlated projections
FastPCA::scale_matrix_columns_inplace(m, sigmas);
//fh_orig_scaled.write(m, append_to_file);
if (use_dih_shifts) {
//TODO: check if this is working
FastPCA::Periodic::shift_matrix_columns_inplace(m, dih_shifts, scaled_periodicities);
//fh_corr_shift.write(m, append_to_file);
}
}
// output
Expand Down

0 comments on commit ccaff4e

Please sign in to comment.