33#if !defined(LOOS_BCOMLIB_HPP)
34#define LOOS_BCOMLIB_HPP
50namespace Convergence {
56 std::vector<float> avg(model.size() * 3);
58 for (uint i=0; i<model.size(); ++i) {
65 for (uint i=0; i<M.cols(); ++i)
66 for (uint j=0; j<M.rows(); ++j)
72 double cosineContent(T& V,
const uint col) {
77 double k = (col+1) * M_PI / m;
78 for (uint j=0; j<m; ++j) {
79 sum1 += cos(k * j) * V(j, col);
80 sum2 += V(j, col) * V(j, col);
82 double c = 2.0 * sum1 * sum1 / (sum2 * m);
103 struct AlignToPolicy {
104 AlignToPolicy(
const loos::AtomicGroup& targ) : target(targ), local_average(true) { }
105 AlignToPolicy(
const loos::AtomicGroup& targ,
const bool flag) : target(targ), local_average(flag) { }
108 for (std::vector<loos::AtomicGroup>::iterator i = ensemble.begin(); i != ensemble.end(); ++i)
109 (*i).alignOnto(target);
114 subtractStructure(M, avg);
116 subtractStructure(M, target);
127 struct NoAlignPolicy {
128 NoAlignPolicy() : local_average(true) { }
129 NoAlignPolicy(
const loos::AtomicGroup& avg_) : avg(avg_), local_average(false) { }
130 NoAlignPolicy(
const loos::AtomicGroup& avg_,
const bool flag) : avg(avg_), local_average(flag) { }
137 subtractStructure(M, lavg);
139 subtractStructure(M, avg);
155 template<
class ExtractPolicy>
156 boost::tuple<loos::RealMatrix, loos::RealMatrix> pca(std::vector<loos::AtomicGroup>& ensemble, ExtractPolicy& extractor) {
170 ssyev_(&jobz, &uplo, &n, C.get(), &lda, W.get(), &dummy, &lwork, &info);
175 lwork =
static_cast<f77int
>(dummy);
176 float *work =
new float[lwork+1];
178 ssyev_(&jobz, &uplo, &n, C.get(), &lda, W.get(), work, &lwork, &info);
186 for (uint j=0; j<W.rows(); ++j)
190 boost::tuple<loos::RealMatrix, loos::RealMatrix> result(W, C);
201 template<
class ExtractPolicy>
202 loos::RealMatrix rsv(std::vector<loos::AtomicGroup>& ensemble, ExtractPolicy& extractor) {
216 ssyev_(&jobz, &uplo, &n, C.get(), &lda, W.get(), &dummy, &lwork, &info);
221 lwork =
static_cast<f77int
>(dummy);
222 float *work =
new float[lwork+1];
224 ssyev_(&jobz, &uplo, &n, C.get(), &lda, W.get(), work, &lwork, &info);
232 for (uint j=0; j<W.rows(); ++j)
233 W[j] = W[j] < 0 ? 0.0 : sqrt(W[j]);
236 for (uint i=0; i<C.cols(); ++i) {
237 double konst = (W[i] > 0.0) ? (1.0/W[i]) : 0.0;
239 for (uint j=0; j<C.rows(); ++j)
Class for handling groups of Atoms (pAtoms, actually)
Definition AtomicGroup.hpp:108
Simple matrix template class using policy classes to determine behavior.
Definition MatrixImpl.hpp:148
Exception caused by a blas/atlas error.
Definition exceptions.hpp:96
RealMatrix MMMultiply(const RealMatrix &A, const RealMatrix &B, const bool transa, const bool transb)
Matrix-matrix multiply (using BLAS)
Definition MatrixOps.cpp:170
T transpose(const T &A)
Transposes a matrix.
Definition MatrixOps.hpp:174
AtomicGroup averageStructure(const std::vector< AtomicGroup > &ensemble)
Compute the average structure of a set of AtomicGroup objects.
Definition ensembles.cpp:36