Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResidualDipolarCouplingEnergy_Rohl.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file core/scoring/methods/ResidualDipolarCouplingEnergy_Rohl.cc
10 /// @brief RDC energy - comparing experimental RDC values to calculated values
11 /// @author Srivatsan Raman
12 
13 
14 //Unit headers
19 
20 //Package headers
21 
23 //#include <core/scoring/ScoringManager.hh>
24 // AUTO-REMOVED #include <core/scoring/EnergyGraph.hh>
25 #include <core/pose/Pose.hh>
26 //#include <core/pose/datacache/CacheableDataType.hh>
27 
28 //numeric headers
29 #include <numeric/numeric.functions.hh>
30 #include <numeric/xyzMatrix.hh>
31 #include <numeric/xyzVector.hh>
32 #include <numeric/xyz.functions.hh>
33 
34 //utility headers
35 // AUTO-REMOVED #include <utility/vector1.hh>
36 #include <utility/exit.hh>
37 
38 //Objexx headers
39 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
40 // AUTO-REMOVED #include <ObjexxFCL/char.functions.hh>
41 // AUTO-REMOVED #include <ObjexxFCL/string.functions.hh>
42 #include <ObjexxFCL/Fmath.hh>
43 
44 //C++ headers
45 #include <iostream>
46 
47 //Auto Headers
48 #include <platform/types.hh>
50 #include <utility/vector1.hh>
51 #include <ObjexxFCL/Dimension.hh>
52 #include <ObjexxFCL/FArray1D.hh>
53 #include <ObjexxFCL/FArray2D.hh>
54 #include <algorithm>
55 #include <cassert>
56 #include <cmath>
57 #include <cstddef>
58 #include <cstdio>
59 #include <cstdlib>
60 #include <iomanip>
61 #include <iosfwd>
62 #include <limits>
63 #include <list>
64 #include <map>
65 #include <ostream>
66 #include <sstream>
67 #include <string>
68 #include <vector>
69 #include <boost/bind.hpp>
70 #include <boost/function.hpp>
71 
72 //Auto using namespaces
73 namespace std { } using namespace std; // AUTO USING NS
74 namespace ObjexxFCL { } using namespace ObjexxFCL; // AUTO USING NS
75 namespace ObjexxFCL { namespace fmt { } } using namespace ObjexxFCL::fmt; // AUTO USING NS
76 //Auto using namespaces end
77 
78 namespace core {
79 namespace scoring {
80 namespace methods {
81 
82 using namespace ObjexxFCL;
83 
84 /// @details This must return a fresh instance of the ResidualDipolarCouplingEnergy_Rohl class,
85 /// never an instance already in use
87 ResidualDipolarCouplingEnergy_RohlCreator::create_energy_method(
89 ) const {
91 }
92 
94 ResidualDipolarCouplingEnergy_RohlCreator::score_types_for_method() const {
95  ScoreTypes sts;
96  sts.push_back( rdc_rohl );
97  return sts;
98 }
99 
100 
101 //////////////////////////////////////////////////////
102 //@brief
103 //////////////////////////////////////////////////////
104 ResidualDipolarCouplingEnergy_Rohl::ResidualDipolarCouplingEnergy_Rohl() :
106 {}
107 
108 
109 //////////////////////////////////////////////////////
110 //@brief
111 //////////////////////////////////////////////////////
114 {
116 }
117 
118 //////////////////////////////////////////////////////
119 //@brief
120 //////////////////////////////////////////////////////
122  pose::Pose & pose,
123  ScoreFunction const &,
124  EnergyMap & totals
125 ) const
126 {
127 
128  Real dipolar_score = eval_dipolar( pose );
129  totals[ rdc_rohl ] = dipolar_score;
130 
131 }
132 
133 //////////////////////////////////////////////////////
134 //@brief
135 //////////////////////////////////////////////////////
138  pose::Pose & pose
139 ) const
140 {
141 // //using core::pose::datacache::CacheableDataType::RESIDUAL_DIPOLAR_COUPLING_DATA;
142 
143 // if( pose.data().has( RESIDUAL_DIPOLAR_COUPLING_DATA ) )
144 // return *( static_cast< ResidualDipolarCoupling const * >( pose.data().get_const_ptr( RESIDUAL_DIPOLAR_COUPLING_DATA )() ) );
145 
146 // ResidualDipolarCouplingOP rdc_info = new ResidualDipolarCoupling;
147 // pose.data().set( RESIDUAL_DIPOLAR_COUPLING_DATA, rdc_info );
149  if ( !rdc_info ) {
150  rdc_info = new ResidualDipolarCoupling_Rohl;
151  store_RDC_ROHL_in_pose( rdc_info, pose );
152  }
153  return *rdc_info;
154 }
155 
156 //////////////////////////////////////////////////////
157 //@brief main computation routine for RDC energy... everything is happening here right now.
158 // this has to be spread out over different routines to make this energy yield derivatives
159 //////////////////////////////////////////////////////
161  pose::Pose & pose
162 ) const
163 {
164 
165  ResidualDipolarCoupling_Rohl const & rdc_data( rdc_from_pose( pose ) );
166  utility::vector1< core::scoring::RDC_Rohl > All_RDC_lines( rdc_data.get_RDC_data() );
167 
168  Size const nrow( All_RDC_lines.size() ); //number of experimental couplins
169  Size const ORDERSIZE = { 5 }; //Syy,Szz,Sxy,Sxz,Syz
170 
171  ObjexxFCL::FArray2D< Real > A( nrow, ORDERSIZE ); // N x 5, the 5 assymetric tensor elements per relevant vector in pose
172  ObjexxFCL::FArray1D< Real > b( nrow ); // experimental values
173  ObjexxFCL::FArray1D< Real > x( ORDERSIZE ); //previously dimensioned to nrow, which is wrong.
174  ObjexxFCL::FArray1D< Real > weights( nrow ); //previously dimensioned to nrow, which is wrong.
175  ObjexxFCL::FArray2D< Real > vec( 3, 3 );
176  Real Azz, eta;
177  bool reject = false;
178 
179 
180  assemble_datamatrix( pose, All_RDC_lines, A, b, weights);
181  /* for ( core::Size i = 1; i <= nrow; ++i ) {
182  std::cout << "Matrices A & b " << A(i,1) << " " << A(i,2) << " " << A(i,3) << " " << A(i,4) << " " << A(i,5) << " " << b(i) << std::endl;
183  }
184  */
185  calc_ordermatrix( nrow, ORDERSIZE, A, b, x, weights, reject );
186  if( reject ) std::cout << "SET SCORE VALUE, FIX THIS LATER " << std::endl;
187  calc_orderparam( x, vec, Azz, eta );
188  Real score( calc_dipscore( A, x, b, All_RDC_lines, ORDERSIZE, Azz )*nrow );
189 
190  return score;
191 
192 }
193 
194 //////////////////////////////////////////////////////
195 //@brief
196 //////////////////////////////////////////////////////
198  pose::Pose const & pose,
199  utility::vector1< core::scoring::RDC_Rohl> const & All_RDC_lines,
200  ObjexxFCL::FArray2D< Real > & A,
201  ObjexxFCL::FArray1D< Real > & b,
202  ObjexxFCL::FArray1D< Real > & weights
203 ) const
204 {
205 
206 
209  Size nrow( 0 );
210 
211  for( it = All_RDC_lines.begin(); it != All_RDC_lines.end(); ++it) {
212 
213  ++nrow;
214  umn = pose.residue(it->res()).atom("N").xyz() - pose.residue(it->res()).atom("H").xyz();
215 
216  Real umn_x = umn.x()/it->fixed_dist();
217  Real umn_y = umn.y()/it->fixed_dist();
218  Real umn_z = umn.z()/it->fixed_dist();
219 
220  //filling matrix A
221  A( nrow, 1 ) = umn_y*umn_y - umn_x*umn_x;
222  A( nrow, 2 ) = umn_z*umn_z - umn_x*umn_x;
223  A( nrow, 3 ) = 2.0*umn_x*umn_y;
224  A( nrow, 4 ) = 2.0*umn_x*umn_z;
225  A( nrow, 5 ) = 2.0*umn_z*umn_y;
226 
227  //filling matrix b
228  b( nrow ) = it->Reduced_Jdipolar();
229  weights( nrow ) = it->weight();
230  // std::cout << "nrow " << nrow << std::endl;
231  // std::cout << "Matrix A " << A(nrow,1) << " " << A(nrow,2) << " " << A(nrow,3) << " " << A(nrow,4) << " " << A(nrow,5) << std::endl;
232  }
233 
234 
235 }
236 
237 ////////////////////////////////////////////////////////////////
238 //
239 ////////////////////////////////////////////////////////////////
241  Size const & nrow,
242  Size const & ORDERSIZE,
243  ObjexxFCL::FArray2D< Real > & A,
244  ObjexxFCL::FArray1D< Real > & b,
245  ObjexxFCL::FArray1D< Real > & x,
246  ObjexxFCL::FArray1D< Real > & weights,
247  bool & reject
248 ) const
249 {
250 
251 
252  core::Real factor = { 1e-6 }; // cutoff factor for singular values in svd
253 
254  ObjexxFCL::FArray2D< Real > U( nrow, ORDERSIZE );
255  ObjexxFCL::FArray1D< Real > w( ORDERSIZE ); // singular values
256  ObjexxFCL::FArray2D< Real > v( ORDERSIZE, ORDERSIZE );
257  ObjexxFCL::FArray1D< Real > bweighted( nrow ); // singular values
258  Real wmin, wmax; // min and max values of w
259  Size sing; // number of singular values in w
260  Real Sxx;
261 
262  // why not U=A; ? should even be faster!
263  Size ct_align = 0;
264  for( core::Size i = 1; i <= nrow; ++i ) { // copy A
265  if ( weights( i ) > 0.000001 ) {
266  ++ct_align;
267  U( ct_align, 1 ) = A(i,1) * weights( i ); // copy into U
268  U( ct_align, 2 ) = A(i,2) * weights( i );
269  U( ct_align, 3 ) = A(i,3) * weights( i );
270  U( ct_align, 4 ) = A(i,4) * weights( i );
271  U( ct_align, 5 ) = A(i,5) * weights( i );
272  bweighted( ct_align ) = b( i ) * weights( i );
273  }
274  }
275 
276  svdcmp( U, ct_align, ORDERSIZE, w, v );
277 
278  wmax = 0.0;
279  for ( core::Size j = 1; j <= ORDERSIZE; ++j ) {
280  if ( w(j) > wmax ) wmax = w(j);
281  }
282  wmin = wmax * factor;
283  sing = 0;
284  for ( core::Size j = 1; j <= ORDERSIZE; ++j ) {
285  if ( w(j) < wmin ) {
286  w(j) = 0.0;
287  ++sing;
288  }
289  }
290  if ( (int)sing > std::abs( int( ct_align ) - int( ORDERSIZE ) ) )
291  std::cout << "SVD yielded a matrix singular above expectation " <<
292  "in get_ordermatrix" << std::endl;
293 
294  // find solution for exact dipolar values
295 
296  svbksb( U, w, v, ct_align, ORDERSIZE, bweighted, x );
297 
298 // x components: (Syy,Szz,Sxy,Sxz,Syz)
299 // check for acceptable values
300 
301  reject = false;
302  Sxx = -x(1) - x(2);
303  if ( Sxx < -0.5 || Sxx > 1.0 ) reject = true; // Sxx
304  if ( x(1) < -0.5 || x(1) > 1.0 ) reject = true; // Syy
305  if ( x(2) < -0.5 || x(2) > 1.0 ) reject = true; // Szz
306  if ( x(3) < -0.75 || x(3) > 0.75 ) reject = true; // Sxy
307  if ( x(4) < -0.75 || x(4) > 0.75 ) reject = true; // Sxz
308  if ( x(5) < -0.75 || x(5) > 0.75 ) reject = true; // Syz
309 
310  if ( reject ) {
311  std::cout << "order matrix not physically meaningful" << std::endl;
312 // try with errors on dipolar values? map error?
313 // score = 0.0;
314  return;
315  }
316 
317 
318 
319 }
320 
321 
322 ////////////////////////////////////////////////////////////////
323 //
324 ////////////////////////////////////////////////////////////////
326  ObjexxFCL::FArray2D< Real > & a,
327  Size const & m,
328  Size const & n,
329  ObjexxFCL::FArray1D< Real > & w,
330  ObjexxFCL::FArray2D< Real > & v
331 ) const
332 {
333 
334 //U USES pythag
335  Size i,its,j,jj,k,l,nm;
336  ObjexxFCL::FArray1D< core::Real > rv1( n );
337  Real anorm, c, f, g, h, s, scale, x, y, z;
338  g = 0.0;
339  scale = 0.0;
340  anorm = 0.0;
341  l = 0;
342  nm = 0;
343  for ( i = 1; i <= n; ++i ) {
344  l = i+1;
345  rv1(i) = scale*g;
346  g = 0.0;
347  s = 0.0;
348  scale = 0.0;
349  if ( i <= m ) {
350  for ( k = i; k <= m; ++k ) {
351  scale += std::abs(a(k,i));
352  }
353  if ( scale != 0.0 ) {
354  for ( k = i; k <= m; ++k ) {
355  a(k,i) /= scale;
356  s += a(k,i)*a(k,i);
357  }
358  f = a(i,i);
359  g = -sign(std::sqrt(s),f);
360  h = f*g-s;
361  a(i,i) = f-g;
362  for ( j = l; j <= n; ++j ) {
363  s = 0.0;
364  for ( k = i; k <= m; ++k ) {
365  s += a(k,i)*a(k,j);
366  }
367  f = s/h;
368  for ( k = i; k <= m; ++k ) {
369  a(k,j) += f*a(k,i);
370  }
371  }
372  for ( k = i; k <= m; ++k ) {
373  a(k,i) *= scale;
374  }
375  }
376  }
377  w(i) = scale *g;
378  g = 0.0;
379  s = 0.0;
380  scale = 0.0;
381  if ( (i <= m) && (i != n) ) {
382  for ( k = l; k <= n; ++k ) {
383  scale += std::abs(a(i,k));
384  }
385  if ( scale != 0.0 ) {
386  for ( k = l; k <= n; ++k ) {
387  a(i,k) /= scale;
388  s += a(i,k)*a(i,k);
389  }
390  f = a(i,l);
391  g = -sign(std::sqrt(s),f);
392  h = f*g-s;
393  a(i,l) = f-g;
394  for ( k = l; k <= n; ++k ) {
395  rv1(k) = a(i,k)/h;
396  }
397  for ( j = l; j <= m; ++j ) {
398  s = 0.0;
399  for ( k = l; k <= n; ++k ) {
400  s += a(j,k)*a(i,k);
401  }
402  for ( k = l; k <= n; ++k ) {
403  a(j,k) += s*rv1(k);
404  }
405  }
406  for ( k = l; k <= n; ++k ) {
407  a(i,k) *= scale;
408  }
409  }
410  }
411  anorm = std::max(anorm,(std::abs(w(i))+std::abs(rv1(i))));
412  }
413  for ( i = n; i >= 1; --i ) {
414  if ( i < n ) {
415  if ( g != 0.0 ) {
416  for ( j = l; j <= n; ++j ) {
417  v(j,i) = (a(i,j)/a(i,l))/g;
418  }
419  for ( j = l; j <= n; ++j ) {
420  s = 0.0;
421  for ( k = l; k <= n; ++k ) {
422  s += a(i,k)*v(k,j);
423  }
424  for ( k = l; k <= n; ++k ) {
425  v(k,j) += s*v(k,i);
426  }
427  }
428  }
429  for ( j = l; j <= n; ++j ) {
430  v(i,j) = 0.0;
431  v(j,i) = 0.0;
432  }
433  }
434  v(i,i) = 1.0;
435  g = rv1(i);
436  l = i;
437  }
438  for ( i = std::min(m,n); i >= 1; --i ) {
439  l = i+1;
440  g = w(i);
441  for ( j = l; j <= n; ++j ) {
442  a(i,j) = 0.0;
443  }
444  if ( g != 0.0 ) {
445  g = 1.0/g;
446  for ( j = l; j <= n; ++j ) {
447  s = 0.0;
448  for ( k = l; k <= m; ++k ) {
449  s += a(k,i)*a(k,j);
450  }
451  f = (s/a(i,i))*g;
452  for ( k = i; k <= m; ++k ) {
453  a(k,j) += f*a(k,i);
454  }
455  }
456  for ( j = i; j <= m; ++j ) {
457  a(j,i) *= g;
458  }
459  } else {
460  for ( j = i; j <= m; ++j ) {
461  a(j,i) = 0.0;
462  }
463  }
464  a(i,i) += 1.0;
465  }
466  for ( k = n; k >= 1; --k ) {
467  for ( its = 1; its <= 30; ++its ) {
468  for ( l = k; l >= 1; --l ) {
469  nm = l-1;
470  if ( (std::abs(rv1(l))+anorm) == anorm ) goto L2;
471  if ( (std::abs(w(nm))+anorm) == anorm ) goto L1;
472  }
473 L1:
474  c = 0.0;
475  s = 1.0;
476  for ( i = l; i <= k; ++i ) {
477  f = s*rv1(i);
478  rv1(i) *= c;
479  if ( (std::abs(f)+anorm) == anorm ) goto L2;
480  g = w(i);
481  h = pythag(f,g);
482  w(i) = h;
483  h = 1.0/h;
484  c = (g*h);
485  s = -(f*h);
486  for ( j = 1; j <= m; ++j ) {
487  y = a(j,nm);
488  z = a(j,i);
489  a(j,nm) = (y*c)+(z*s);
490  a(j,i) = -(y*s)+(z*c);
491  }
492  }
493 L2:
494  z = w(k);
495  if ( l == k ) {
496  if ( z < 0.0 ) {
497  w(k) = -z;
498  for ( j = 1; j <= n; ++j ) {
499  v(j,k) = -v(j,k);
500  }
501  }
502  goto L3;
503  }
504  if ( its == 30) utility_exit_with_message("no convergence in svdcmp \n" );
505  x = w(l);
506  nm = k-1;
507  y = w(nm);
508  g = rv1(nm);
509  h = rv1(k);
510  f = ((y-z)*(y+z)+(g-h)*(g+h))/(2.0*h*y);
511  g = pythag(f,1.0);
512  f = ((x-z)*(x+z)+h*((y/(f+sign(g,f)))-h))/x;
513  c = 1.0;
514  s = 1.0;
515  for ( j = l; j <= nm; ++j ) {
516  i = j+1;
517  g = rv1(i);
518  y = w(i);
519  h = s*g;
520  g *= c;
521  z = pythag(f,h);
522  rv1(j) = z;
523  c = f/z;
524  s = h/z;
525  f = (x*c)+(g*s);
526  g = -(x*s)+(g*c);
527  h = y*s;
528  y *= c;
529  for ( jj = 1; jj <= n; ++jj ) {
530  x = v(jj,j);
531  z = v(jj,i);
532  v(jj,j) = (x*c)+(z*s);
533  v(jj,i) = -(x*s)+(z*c);
534  }
535  z = pythag(f,h);
536  w(j) = z;
537  if ( z != 0.0 ) {
538  z = 1.0/z;
539  c = f*z;
540  s = h*z;
541  }
542  f = (c*g)+(s*y);
543  x = -(s*g)+(c*y);
544  for ( jj = 1; jj <= m; ++jj ) {
545  y = a(jj,j);
546  z = a(jj,i);
547  a(jj,j) = (y*c)+(z*s);
548  a(jj,i) = -(y*s)+(z*c);
549  }
550  }
551  rv1(l) = 0.0;
552  rv1(k) = f;
553  w(k) = x;
554  }
555 L3:;
556  }
557 
558 
559 }
560 ////////////////////////////////////////////////////////////////
561 //
562 ////////////////////////////////////////////////////////////////
564  Real const & a,
565  Real const & b
566 ) const
567 {
568 
569  Real pythag;
570 
571  Real absa = std::abs(a);
572  Real absb = std::abs(b);
573  if ( absa > absb ) {
574  Real const ratio = absb/absa;
575  pythag = absa * std::sqrt( 1.0 + ( ratio * ratio ) );
576  } else {
577  if ( absb == 0.0 ) {
578  pythag = 0.0;
579  } else {
580  Real const ratio = absa/absb;
581  pythag = absb * std::sqrt( 1.0 + ( ratio * ratio ) );
582  }
583  }
584  return pythag;
585 
586 
587 }
588 ////////////////////////////////////////////////////////////////
589 //
590 ////////////////////////////////////////////////////////////////
592  ObjexxFCL::FArray2D< Real > const & u,
593  ObjexxFCL::FArray1D< Real > const & w,
594  ObjexxFCL::FArray2D< Real > const & v,
595  Size const & m,
596  Size const & n,
597  ObjexxFCL::FArray1D< Real > const & b,
598  ObjexxFCL::FArray1D< Real > & x
599 ) const
600 {
601 
602 
603  ObjexxFCL::FArray1D< core::Real > tmp( n );
604  Real s;
605 
606  for ( Size j = 1; j <= n; ++j ) {
607  s = 0.0;
608  if ( w(j) != 0.0 ) {
609  for ( Size i = 1; i <= m; ++i ) {
610  s += u(i,j) * b(i);
611  }
612  s /= w(j);
613  }
614  tmp(j) = s;
615  }
616  for ( Size j = 1; j <= n; ++j ) {
617  s = 0.0;
618  for ( Size jj = 1; jj <= n; ++jj ) {
619  s += v(j,jj) * tmp(jj);
620  }
621  x(j) = s;
622  }
623 
624 
625 }
626 ////////////////////////////////////////////////////////////////
627 //
628 ////////////////////////////////////////////////////////////////
630  ObjexxFCL::FArray1D< Real > x,
631  ObjexxFCL::FArray2D< Real > vec,
632  Real & Azz,
633  Real & eta
634 ) const
635 {
636 
637  using numeric::xyzMatrix;
638 
639  ObjexxFCL::FArray1D< Size > sort( 3 ); // sorted index to val, val(sort(1)) = largest abs val.
640  Real temp1, temp2;
641 
642  // Assemble order matrix
643  numeric::xyzMatrix< Real > S = numeric::xyzMatrix< core::Real >::rows( -x(1) - x(2), x(3), x(4),x(3), x(1), x(5), x(4), x(5), x(2) );
644 
645 
646  numeric::xyzVector< Real > val; // Eigenvalues
647  numeric::xyzMatrix< Real > xyz_vec; // Eigenvectors
648 
649  // Find eigenvalues, eigenvectors of symmetric matrix S
650  val = eigenvector_jacobi( S, 1E-9, xyz_vec );
651 
652  // sort eigenvalues
653  sort(1) = 1;
654  sort(2) = 2;
655  sort(3) = 3;
656 
657  if ( std::abs(val(1)) < std::abs(val(2)) ) { // largest absolute value
658  sort(2) = 1;
659  sort(1) = 2;
660  }
661  if ( std::abs(val(sort(2))) < std::abs(val(3)) ) {
662  sort(3) = sort(2);
663  sort(2) = 3;
664  if ( std::abs(val(sort(1))) < std::abs(val(3)) ) {
665  sort(2) = sort(1);
666  sort(1) = 3;
667  }
668  }
669 
670 
671  Azz = val(sort(1));
672  eta = (2.0/3.0) * std::abs(val(sort(2))-val(sort(3))/Azz);
673 
674 // sort eigen values // largest to smallest : Azz,Ayy,Axx
675  temp1 = val(sort(1));
676  temp2 = val(sort(2));
677  val(3) = val(sort(3));
678  val(2) = temp2;
679  val(1) = temp1;
680 
681 // sort eigen vectors
682  for ( Size i = 1; i <= 3; ++i ) {
683  temp1 = xyz_vec(i,sort(3));
684  temp2 = xyz_vec(i,sort(2));
685  vec(i,3) = xyz_vec(i,sort(1));
686  vec(i,1) = temp1;
687  vec(i,2) = temp2;
688  }
689 
690  Azz = val(1);
691  eta = (2.0/3.0) * (val(3)-val(2))/val(1);
692 
693 
694 
695 }
696 ////////////////////////////////////////////////////////////////
697 //
698 ////////////////////////////////////////////////////////////////
700  ObjexxFCL::FArray2D< Real > const & A,
701  ObjexxFCL::FArray1D< Real > const & x,
702  ObjexxFCL::FArray1D< Real > const & b,
703  utility::vector1< core::scoring::RDC_Rohl > const & All_RDC_lines,
704  Size const & ORDERSIZE,
705  Real const & Azz
706 ) const
707 {
708 
709  assert( Azz != 0 );
710 
711  Real score( 0.0 );
712 
714  Size nrow( 0 );
715  for( it = All_RDC_lines.begin(); it != All_RDC_lines.end(); ++it) {
716  Real Jcalc( 0.0 );
717  ++nrow;
718  for( Size j = 1; j <= ORDERSIZE; ++j ) {
719  Jcalc += A( nrow, j )*x(j);
720  }
721  score += ( b( nrow ) -Jcalc )*( b( nrow ) - Jcalc ); //these are reduced Jd
722 
723  //v std::cout << b(nrow)/it->invDcnst() << " " << Jcalc/it->invDcnst() << " " << numeric::square( b(nrow)/it->invDcnst() - Jcalc/it->invDcnst() ) << " " << it->res() << std::endl;
724  }
725 
726  //std::cout << "score, nrow, Azz " << score << " " << nrow << " " << Azz << std::endl;
727 
728  score /= ( nrow*( Azz*Azz ) );
729 
730  //std::cout << "Total score " << score << std::endl;
731 
732  return score;
733 
734 }
737 {
738  return 1; // Initial versioning
739 }
740 
741 
742 } // methods
743 } // scoring
744 } // core