LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
Loading...
Searching...
No Matches
anm-lib.hpp
1/*
2 This file is part of LOOS.
3
4 LOOS (Lightweight Object-Oriented Structure library)
5 Copyright (c) 2010, Tod D. Romo, Alan Grossfield
6 Department of Biochemistry and Biophysics
7 School of Medicine & Dentistry, University of Rochester
8
9 This package (LOOS) is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation under version 3 of the License.
12
13 This package is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
26#if !defined(LOOS_ANM_LIB_HPP)
27#define LOOS_ANM_LIB_HPP
28
29
30#include "enm-lib.hpp"
31
32namespace ENM {
33
35 class ANM : public ElasticNetworkModel {
36 public:
37 ANM(SuperBlock* b) : ElasticNetworkModel(b) { prefix_ = "anm"; }
38
39 void solve() {
40
41 if (verbosity_ > 2)
42 std::cerr << "Building hessian...\n";
44 if (debugging_)
45 loos::writeAsciiMatrix(prefix_ + "_H.asc", hessian_, meta_, false);
46
48 if (verbosity_ > 1)
49 std::cerr << "Computing SVD of hessian...\n";
50 t.start();
51
52 boost::tuple<loos::DoubleMatrix, loos::DoubleMatrix, loos::DoubleMatrix> result = svd(hessian_);
53
54 t.stop();
55 if (verbosity_ > 1)
56 std::cerr << "SVD took " << loos::timeAsString(t.elapsed()) << std::endl;
57
58
59 eigenvecs_ = boost::get<0>(result);
60 eigenvals_ = boost::get<1>(result);
61 rsv_ = boost::get<2>(result);
62
63 loos::Math::reverseRows(eigenvals_);
64 loos::Math::reverseColumns(eigenvecs_);
65 loos::Math::reverseRows(rsv_);
66 }
67
68
71
72 if (rsv_.rows() == 0)
73 throw(std::logic_error("ANM::inverseHessian() called before ANM::solve()"));
74
75 uint n = eigenvals_.rows();
76 for (uint i=6; i<n; ++i) {
77 double s = 1.0 / eigenvals_[i];
78 for (uint j=0; j<n; ++j)
79 rsv_(i, j) *= s;
80 }
81
82 loos::DoubleMatrix Hi = loos::Math::MMMultiply(rsv_, eigenvecs_, true, true);
83 return(Hi);
84 }
85
86
87 private:
89
90 };
91
92};
93
94#endif
95
96
Anisotropic network model.
Definition anm-lib.hpp:35
loos::DoubleMatrix inverseHessian()
Return the inverted hessian matrix.
Definition anm-lib.hpp:70
void solve()
Computes the hessian and solves for the eigenpairs.
Definition anm-lib.hpp:39
Interface for all ENMs.
Definition enm-lib.hpp:67
ElasticNetworkModel(SuperBlock *blocker)
Base constructor for all ENMs.
Definition enm-lib.hpp:75
void buildHessian()
Construct the hessian using the contained SuperBlock.
Definition enm-lib.cpp:84
This class creates superblocks in a hessian.
Definition hessian.hpp:52
Simple matrix template class using policy classes to determine behavior.
Definition MatrixImpl.hpp:148
Class for tracking time.
Definition loos_timer.hpp:80
Namespace to encapsulate Elastic Network Model routines.
Definition anm-lib.hpp:32
RealMatrix MMMultiply(const RealMatrix &A, const RealMatrix &B, const bool transa, const bool transb)
Matrix-matrix multiply (using BLAS)
Definition MatrixOps.cpp:170
std::ostream & writeAsciiMatrix(std::ostream &os, const Math::Matrix< T, P, S > &M, const std::string &meta, const Math::Range &start, const Math::Range &end, const bool trans=false, F fmt=F())
Write a submatrix to a stream.
Definition MatrixWrite.hpp:140
std::string timeAsString(const double t, const uint precision)
Convert t (seconds) into a string, converting to hours and minutes as necessary.
Definition utils.cpp:203