#include <colvarvalue.h>
Public Types | |
| enum | Type { type_notset, type_scalar, type_vector, type_unitvector, type_quaternion } |
| Possible types of value. More... | |
Public Member Functions | |
| colvarvalue () | |
| Default constructor: this class defaults to a scalar number and always behaves like it unless you change its type. | |
| colvarvalue (Type const &vti) | |
| Constructor from a type specification. | |
| colvarvalue (cvm::real const &x) | |
| Copy constructor from real base type. | |
| colvarvalue (cvm::rvector const &v) | |
| Copy constructor from rvector base type (Note: this sets automatically a type , if you want a you must set it explicitly). | |
| colvarvalue (cvm::rvector const &v, Type const &vti) | |
| Copy constructor from rvector base type (additional argument to make possible to choose a . | |
| colvarvalue (cvm::quaternion const &q) | |
| Copy constructor from quaternion base type. | |
| colvarvalue (colvarvalue const &x) | |
| Copy constructor from another . | |
| void | reset () |
| Set to the null value for the data type currently defined. | |
| void | apply_constraints () |
| If the variable has constraints (e.g. unitvector or quaternion), transform it to satisfy them; use it when the is not calculated from objects, but manipulated by you. | |
| Type | type () const |
| Get the current type. | |
| void | type (Type const &vti) |
| Set the type explicitly. | |
| void | type (colvarvalue const &x) |
| Set the type after another . | |
| cvm::real | norm2 () const |
| Square norm of this colvarvalue. | |
| cvm::real | norm () const |
| Norm of this colvarvalue. | |
| colvarvalue | inverse () const |
| Return the value whose scalar product with this value is 1. | |
| cvm::real | dist2 (colvarvalue const &x2) const |
| Square distance between this and another. | |
| colvarvalue | dist2_grad (colvarvalue const &x2) const |
| Derivative with respect to this of the square distance. | |
| colvarvalue & | operator= (colvarvalue const &x) |
| Assignment operator (type of x is checked). | |
| void | operator+= (colvarvalue const &x) |
| void | operator-= (colvarvalue const &x) |
| void | operator *= (cvm::real const &a) |
| void | operator/= (cvm::real const &a) |
| operator cvm::real () const | |
| operator cvm::rvector () const | |
| operator cvm::quaternion () const | |
| bool | is_scalar () |
| Special case when the variable is a real number, and all operations are defined. | |
| void | undef_op () const |
| Undefined operation. | |
| void | error_lside (Type const &vt) const |
| void | error_rside (Type const &vt) const |
| size_t | output_width (size_t const &real_width) |
Static Public Member Functions | |
| bool | type_checking () |
| void | check_types (colvarvalue const &x1, colvarvalue const &x2) |
| Ensure that the two types are the same within a binary operator. | |
| void | inner_opt (colvarvalue const &x, std::vector< colvarvalue >::iterator &xv, std::vector< colvarvalue >::iterator const &xv_end, std::vector< cvm::real >::iterator &inner) |
| Optimized routine for the inner product of one collective variable with an array. | |
| void | inner_opt (colvarvalue const &x, std::list< colvarvalue >::iterator &xv, std::list< colvarvalue >::iterator const &xv_end, std::vector< cvm::real >::iterator &inner) |
| Optimized routine for the inner product of one collective variable with an array. | |
| void | p2leg_opt (colvarvalue const &x, std::vector< colvarvalue >::iterator &xv, std::vector< colvarvalue >::iterator const &xv_end, std::vector< cvm::real >::iterator &inner) |
| Optimized routine for the second order Legendre polynomial, (3cos^2(w)-1)/2, of one collective variable with an array. | |
| void | p2leg_opt (colvarvalue const &x, std::list< colvarvalue >::iterator &xv, std::list< colvarvalue >::iterator const &xv_end, std::vector< cvm::real >::iterator &inner) |
| Optimized routine for the second order Legendre polynomial of one collective variable with an array. | |
Public Attributes | |
| cvm::real | real_value |
| Real data member. | |
| cvm::rvector | rvector_value |
| Vector data member. | |
| cvm::quaternion | quaternion_value |
| Quaternion data member. | |
| Type | value_type |
| Current type of this colvarvalue object. | |
Static Public Attributes | |
| std::string const | type_desc [colvarvalue::type_quaternion+1] |
| Runtime description of value types. | |
| size_t const | dof_num [colvarvalue::type_quaternion+1] |
| Number of degrees of freedom for each type. | |
allows to be treat different data types. By default, a variable is a scalar number. If you want to use it as another type, you should declare and initialize a variable as
colvarvalue x (colvarvalue::type_xxx);
Given a colvarvalue variable x which is not yet assigned (and thus has not yet a type) it is also possible to correctly assign the type with
x = y;
Also, every operator (either unary or binary) on a object performs one or more checks on the to avoid errors such as initializing a three-dimensional vector with a scalar number (legal otherwise).
Special case: when reading from a stream, there is no way to detect the and safely handle errors at the same time. Hence, when using
is >> x;
No problem of course with the output streams:
os << x;
Note on performance: at every operation between two objects, their two flags will be checked for a match. In a long array of objects this is time consuming: a few static functions are defined ("xxx_opt" functions) within the class, which only check the matching once for a large array, and execute different loops according to the type. You should do the same for every time consuming loop involving operations on objects if you want e.g. to optimize your colvar bias.
Definition at line 57 of file colvarvalue.h.
|
|
Possible types of value. These three cover most possibilities of data type one can devise. If you need to implement a new colvar with a very complex data type, it's better to put an allocatable class here
Definition at line 66 of file colvarvalue.h. Referenced by error_lside(), and error_rside(). 00066 {
00068 type_notset,
00070 type_scalar,
00072 type_vector,
00074 type_unitvector,
00076 type_quaternion
00077 };
|
|
|
Default constructor: this class defaults to a scalar number and always behaves like it unless you change its type.
Definition at line 104 of file colvarvalue.h. Referenced by dist2_grad(), and inverse(). 00105 : real_value (0.0), value_type (type_scalar) 00106 {}
|
|
|
Constructor from a type specification.
Definition at line 109 of file colvarvalue.h. 00110 : value_type (vti) 00111 { 00112 reset(); 00113 }
|
|
|
Copy constructor from real base type.
Definition at line 116 of file colvarvalue.h. 00117 : real_value (x), value_type (type_scalar) 00118 {}
|
|
|
Copy constructor from rvector base type (Note: this sets automatically a type , if you want a you must set it explicitly).
Definition at line 123 of file colvarvalue.h. 00124 : rvector_value (v), value_type (type_vector) 00125 {}
|
|
||||||||||||
|
Copy constructor from rvector base type (additional argument to make possible to choose a .
Definition at line 130 of file colvarvalue.h. 00131 : rvector_value (v), value_type (vti) 00132 {}
|
|
|
Copy constructor from quaternion base type.
Definition at line 135 of file colvarvalue.h. 00136 : quaternion_value (q), value_type (type_quaternion) 00137 {}
|
|
|
Copy constructor from another .
Definition at line 140 of file colvarvalue.h. References quaternion_value, real_value, rvector_value, and value_type. 00141 : value_type (x.value_type) 00142 { 00143 reset(); 00144 00145 switch (x.value_type) { 00146 case type_scalar: 00147 real_value = x.real_value; 00148 break; 00149 case type_vector: 00150 case type_unitvector: 00151 rvector_value = x.rvector_value; 00152 break; 00153 case type_quaternion: 00154 quaternion_value = x.quaternion_value; 00155 break; 00156 case type_notset: 00157 default: 00158 break; 00159 } 00160 }
|
|
|
If the variable has constraints (e.g. unitvector or quaternion), transform it to satisfy them; use it when the is not calculated from objects, but manipulated by you.
Definition at line 331 of file colvarvalue.h. References colvarmodule::quaternion::norm2(), colvarmodule::rvector::norm2(), quaternion_value, rvector_value, type_notset, type_quaternion, type_scalar, type_unitvector, and type_vector. Referenced by colvar::calc_runave(), operator>>(), and colvar::update(). 00332 {
00333 switch (value_type) {
00334 case colvarvalue::type_scalar:
00335 break;
00336 case colvarvalue::type_vector:
00337 break;
00338 case colvarvalue::type_unitvector:
00339 rvector_value /= std::sqrt (rvector_value.norm2());
00340 break;
00341 case colvarvalue::type_quaternion:
00342 quaternion_value /= std::sqrt (quaternion_value.norm2());
00343 break;
00344 case colvarvalue::type_notset:
00345 default:
00346 break;
00347 }
00348 }
|
|
||||||||||||
|
Ensure that the two types are the same within a binary operator.
Definition at line 694 of file colvarvalue.h. References colvarmodule::fatal_error(), colvarmodule::log(), type_desc, and value_type. Referenced by dist2(), dist2_grad(), inner_opt(), operator *(), operator+(), operator+=(), operator-(), operator-=(), and p2leg_opt(). 00696 {
00697 if (x1.value_type != x2.value_type) {
00698 cvm::log ("x1 type = "+cvm::to_str (x1.value_type)+
00699 ", x2 type = "+cvm::to_str (x2.value_type)+"\n");
00700 cvm::fatal_error ("Performing an operation between two colvar "
00701 "values with different types, \""+
00702 colvarvalue::type_desc[x1.value_type]+
00703 "\" and \""+
00704 colvarvalue::type_desc[x2.value_type]+
00705 "\".\n");
00706 }
00707 }
|
|
|
Square distance between this and another.
Definition at line 633 of file colvarvalue.h. References check_types(), colvarmodule::quaternion::dist2(), norm2(), quaternion_value, real_value, rvector_value, type_checking(), type_notset, type_quaternion, type_scalar, type_unitvector, type_vector, and undef_op(). Referenced by colvar::cvc::dist2(), and colvar::dist2(). 00634 {
00635 if (colvarvalue::type_checking())
00636 colvarvalue::check_types (*this, x2);
00637
00638 switch (this->value_type) {
00639 case colvarvalue::type_scalar:
00640 return (this->real_value - x2.real_value)*(this->real_value - x2.real_value);
00641 case colvarvalue::type_vector:
00642 return (this->rvector_value - x2.rvector_value).norm2();
00643 case colvarvalue::type_unitvector:
00644 // angle between (*this) and x2 is the distance
00645 return std::acos (this->rvector_value * x2.rvector_value) * std::acos (this->rvector_value * x2.rvector_value);
00646 case colvarvalue::type_quaternion:
00647 // angle between (*this) and x2 is the distance, the quaternion
00648 // object has it implemented internally
00649 return this->quaternion_value.dist2 (x2.quaternion_value);
00650 case colvarvalue::type_notset:
00651 default:
00652 this->undef_op();
00653 return 0.0;
00654 };
00655 }
|
|
|
Derivative with respect to this of the square distance.
Definition at line 658 of file colvarvalue.h. References check_types(), colvarvalue(), colvarmodule::quaternion::dist2_grad(), quaternion_value, real_value, rvector_value, type_checking(), type_notset, type_quaternion, type_scalar, type_unitvector, type_vector, undef_op(), colvarmodule::rvector::x, colvarmodule::rvector::y, and colvarmodule::rvector::z. Referenced by colvar::cvc::dist2_lgrad(), and colvar::cvc::dist2_rgrad(). 00659 {
00660 if (colvarvalue::type_checking())
00661 colvarvalue::check_types (*this, x2);
00662
00663 switch (this->value_type) {
00664 case colvarvalue::type_scalar:
00665 return 2.0 * (this->real_value - x2.real_value);
00666 case colvarvalue::type_vector:
00667 return 2.0 * (this->rvector_value - x2.rvector_value);
00668 case colvarvalue::type_unitvector:
00669 {
00670 cvm::rvector const &v1 = this->rvector_value;
00671 cvm::rvector const &v2 = x2.rvector_value;
00672 cvm::real const cos_t = v1 * v2;
00673 cvm::real const sin_t = std::sqrt (1.0 - cos_t*cos_t);
00674 return colvarvalue ( 2.0 * sin_t *
00675 cvm::rvector ( (-1.0) * sin_t * v2.x +
00676 cos_t/sin_t * (v1.x - cos_t*v2.x),
00677 (-1.0) * sin_t * v2.y +
00678 cos_t/sin_t * (v1.y - cos_t*v2.y),
00679 (-1.0) * sin_t * v2.z +
00680 cos_t/sin_t * (v1.z - cos_t*v2.z)
00681 ),
00682 colvarvalue::type_unitvector );
00683 }
00684 case colvarvalue::type_quaternion:
00685 return this->quaternion_value.dist2_grad (x2.quaternion_value);
00686 case colvarvalue::type_notset:
00687 default:
00688 this->undef_op();
00689 return colvarvalue (colvarvalue::type_notset);
00690 };
00691 }
|
|
|
Trying to assign this object to another object set with a different type Definition at line 34 of file colvarvalue.C. References colvarmodule::fatal_error(), and Type. Referenced by operator=(). 00035 {
00036 cvm::fatal_error ("Trying to use a colvar value with type \""+
00037 type_desc[vt]+"\" as one of type \""+
00038 type_desc[this->value_type]+"\".\n");
00039 }
|
|
|
Trying to assign another object set with a different type to this object Definition at line 26 of file colvarvalue.C. References colvarmodule::fatal_error(), and Type. Referenced by operator cvm::quaternion(), operator cvm::real(), and operator cvm::rvector(). 00027 {
00028 cvm::fatal_error ("Trying to assign a colvar value with type \""+
00029 type_desc[this->value_type]+"\" to one with type \""+
00030 type_desc[vt]+"\".\n");
00031 }
|
|
||||||||||||||||||||
|
Optimized routine for the inner product of one collective variable with an array.
Definition at line 76 of file colvarvalue.C. References check_types(), quaternion_value, real_value, rvector_value, type_quaternion, type_scalar, type_unitvector, type_vector, undef_op(), and value_type. 00080 {
00081 // doing type check only once, here
00082 colvarvalue::check_types (x, *xv);
00083
00084 std::list<colvarvalue>::iterator &xvi = xv;
00085 std::vector<cvm::real>::iterator &ii = inner;
00086
00087 switch (x.value_type) {
00088 case colvarvalue::type_scalar:
00089 while (xvi != xv_end) {
00090 *(ii++) += (xvi++)->real_value * x.real_value;
00091 }
00092 break;
00093 case colvarvalue::type_vector:
00094 case colvarvalue::type_unitvector:
00095 while (xvi != xv_end) {
00096 *(ii++) += (xvi++)->rvector_value * x.rvector_value;
00097 }
00098 break;
00099 case colvarvalue::type_quaternion:
00100 while (xvi != xv_end) {
00101 *(ii++) += ((xvi++)->quaternion_value).cosine (x.quaternion_value);
00102 }
00103 break;
00104 default:
00105 x.undef_op();
00106 };
00107 }
|
|
||||||||||||||||||||
|
Optimized routine for the inner product of one collective variable with an array.
Definition at line 43 of file colvarvalue.C. References check_types(), quaternion_value, real_value, rvector_value, type_quaternion, type_scalar, type_unitvector, type_vector, undef_op(), and value_type. Referenced by colvar::calc_coor_acf(), and colvar::calc_vel_acf(). 00047 {
00048 // doing type check only once, here
00049 colvarvalue::check_types (x, *xv);
00050
00051 std::vector<colvarvalue>::iterator &xvi = xv;
00052 std::vector<cvm::real>::iterator &ii = inner;
00053
00054 switch (x.value_type) {
00055 case colvarvalue::type_scalar:
00056 while (xvi != xv_end) {
00057 *(ii++) += (xvi++)->real_value * x.real_value;
00058 }
00059 break;
00060 case colvarvalue::type_vector:
00061 case colvarvalue::type_unitvector:
00062 while (xvi != xv_end) {
00063 *(ii++) += (xvi++)->rvector_value * x.rvector_value;
00064 }
00065 break;
00066 case colvarvalue::type_quaternion:
00067 while (xvi != xv_end) {
00068 *(ii++) += ((xvi++)->quaternion_value).cosine (x.quaternion_value);
00069 }
00070 break;
00071 default:
00072 x.undef_op();
00073 };
00074 }
|
|
|
|
Special case when the variable is a real number, and all operations are defined.
Definition at line 248 of file colvarvalue.h. 00249 {
00250 return (value_type == type_scalar);
00251 }
|
|
|
Norm of this colvarvalue.
Definition at line 201 of file colvarvalue.h. 00202 {
00203 return std::sqrt (this->norm2());
00204 }
|
|
|
Square norm of this colvarvalue.
Definition at line 352 of file colvarvalue.h. References colvarmodule::quaternion::norm2(), type_notset, type_quaternion, type_scalar, type_unitvector, and type_vector. Referenced by colvar::calc_coor_acf(), colvar::rmsd::calc_value(), colvar::inertia::calc_value(), colvar::gyration::calc_value(), colvar::calc_vel_acf(), dist2(), and colvar::distance_dir::dist2(). 00353 {
00354 switch (value_type) {
00355 case colvarvalue::type_scalar:
00356 return (this->real_value)*(this->real_value);
00357 case colvarvalue::type_vector:
00358 case colvarvalue::type_unitvector:
00359 return (this->rvector_value).norm2();
00360 case colvarvalue::type_quaternion:
00361 return (this->quaternion_value).norm2();
00362 case colvarvalue::type_notset:
00363 default:
00364 return 0.0;
00365 }
00366 }
|
|
|
Definition at line 459 of file colvarvalue.h. References quaternion_value, real_value, rvector_value, type_notset, type_quaternion, type_scalar, type_unitvector, type_vector, and undef_op(). 00460 {
00461 switch (value_type) {
00462 case colvarvalue::type_scalar:
00463 real_value *= a;
00464 break;
00465 case colvarvalue::type_vector:
00466 case colvarvalue::type_unitvector:
00467 rvector_value *= a;
00468 break;
00469 case colvarvalue::type_quaternion:
00470 quaternion_value *= a;
00471 break;
00472 case colvarvalue::type_notset:
00473 default:
00474 undef_op();
00475 }
00476 }
|
|
|
Definition at line 241 of file colvarvalue.h. References error_rside(). 00242 {
00243 if (value_type != type_quaternion) error_rside (type_quaternion);
00244 return quaternion_value;
00245 }
|
|
|
Definition at line 226 of file colvarvalue.h. References error_rside(), and type_scalar. 00227 {
00228 if (value_type != type_scalar) error_rside (type_scalar);
00229 return real_value;
00230 }
|
|
|
Definition at line 233 of file colvarvalue.h. References error_rside(), and type_vector. 00234 {
00235 if ( (value_type != type_vector) && (value_type != type_unitvector))
00236 error_rside (type_vector);
00237 return rvector_value;
00238 }
|
|
|
Definition at line 418 of file colvarvalue.h. References check_types(), quaternion_value, real_value, rvector_value, type_checking(), type_notset, type_quaternion, type_scalar, type_unitvector, type_vector, and undef_op(). 00419 {
00420 if (colvarvalue::type_checking())
00421 colvarvalue::check_types (*this, x);
00422
00423 switch (this->value_type) {
00424 case colvarvalue::type_scalar:
00425 this->real_value += x.real_value;
00426 break;
00427 case colvarvalue::type_vector:
00428 case colvarvalue::type_unitvector:
00429 this->rvector_value += x.rvector_value;
00430 break;
00431 case colvarvalue::type_quaternion:
00432 this->quaternion_value += x.quaternion_value;
00433 break;
00434 case colvarvalue::type_notset:
00435 default:
00436 undef_op();
00437 }
00438 }
|
|
|
Definition at line 440 of file colvarvalue.h. References check_types(), quaternion_value, real_value, rvector_value, type_checking(), type_notset, type_quaternion, type_scalar, type_unitvector, type_vector, and undef_op(). 00441 {
00442 if (colvarvalue::type_checking())
00443 colvarvalue::check_types (*this, x);
00444
00445 switch (value_type) {
00446 case colvarvalue::type_scalar:
00447 real_value -= x.real_value; break;
00448 case colvarvalue::type_vector:
00449 case colvarvalue::type_unitvector:
00450 rvector_value -= x.rvector_value; break;
00451 case colvarvalue::type_quaternion:
00452 quaternion_value -= x.quaternion_value; break;
00453 case colvarvalue::type_notset:
00454 default:
00455 undef_op();
00456 }
00457 }
|
|
|
Definition at line 478 of file colvarvalue.h. References quaternion_value, real_value, rvector_value, type_notset, type_quaternion, type_scalar, type_unitvector, type_vector, and undef_op(). 00479 {
00480 switch (value_type) {
00481 case colvarvalue::type_scalar:
00482 real_value /= a; break;
00483 case colvarvalue::type_vector:
00484 case colvarvalue::type_unitvector:
00485 rvector_value /= a; break;
00486 case colvarvalue::type_quaternion:
00487 quaternion_value /= a; break;
00488 case colvarvalue::type_notset:
00489 default:
00490 undef_op();
00491 }
00492 }
|
|
|
Assignment operator (type of x is checked).
Definition at line 391 of file colvarvalue.h. References error_lside(), quaternion_value, real_value, rvector_value, type_notset, type_quaternion, type_scalar, type_unitvector, type_vector, undef_op(), and value_type. 00392 {
00393 if (this->value_type != type_notset)
00394 if (this->value_type != x.value_type)
00395 error_lside (x.value_type);
00396
00397 this->value_type = x.value_type;
00398
00399 switch (this->value_type) {
00400 case colvarvalue::type_scalar:
00401 this->real_value = x.real_value;
00402 break;
00403 case colvarvalue::type_vector:
00404 case colvarvalue::type_unitvector:
00405 this->rvector_value = x.rvector_value;
00406 break;
00407 case colvarvalue::type_quaternion:
00408 this->quaternion_value = x.quaternion_value;
00409 break;
00410 case colvarvalue::type_notset:
00411 default:
00412 undef_op();
00413 break;
00414 }
00415 return *this;
00416 }
|
|
|
�Give the number of characters required to output this colvarvalue, given the current type assigned and the number of characters for a real number Definition at line 245 of file colvarvalue.C. References type_notset, type_quaternion, type_scalar, type_unitvector, and type_vector. Referenced by colvar::parse_analysis(), and colvar::write_traj_label(). 00246 {
00247 switch (this->value_type) {
00248 case colvarvalue::type_scalar:
00249 return real_width;
00250 case colvarvalue::type_vector:
00251 case colvarvalue::type_unitvector:
00252 return cvm::rvector::output_width (real_width);
00253 case colvarvalue::type_quaternion:
00254 return cvm::quaternion::output_width (real_width);
00255 case colvarvalue::type_notset:
00256 default:
00257 return 0;
00258 }
00259 }
|
|
||||||||||||||||||||
|
Optimized routine for the second order Legendre polynomial of one collective variable with an array.
Definition at line 152 of file colvarvalue.C. References check_types(), colvarmodule::fatal_error(), colvarmodule::rvector::norm(), quaternion_value, rvector_value, type_quaternion, type_scalar, type_unitvector, type_vector, undef_op(), and value_type. 00156 {
00157 // doing type check only once, here
00158 colvarvalue::check_types (x, *xv);
00159
00160 std::list<colvarvalue>::iterator &xvi = xv;
00161 std::vector<cvm::real>::iterator &ii = inner;
00162
00163 switch (x.value_type) {
00164 case colvarvalue::type_scalar:
00165 cvm::fatal_error ("Error: cannot calculate Legendre polynomials "
00166 "for scalar variables.\n");
00167 break;
00168 case colvarvalue::type_vector:
00169 while (xvi != xv_end) {
00170 cvm::real const cosine =
00171 ((xvi)->rvector_value * x.rvector_value) /
00172 ((xvi)->rvector_value.norm() * x.rvector_value.norm());
00173 xvi++;
00174 *(ii++) += 1.5*cosine*cosine - 0.5;
00175 }
00176 break;
00177 case colvarvalue::type_unitvector:
00178 while (xvi != xv_end) {
00179 cvm::real const cosine = (xvi++)->rvector_value * x.rvector_value;
00180 *(ii++) += 1.5*cosine*cosine - 0.5;
00181 }
00182 break;
00183 case colvarvalue::type_quaternion:
00184 while (xvi != xv_end) {
00185 cvm::real const cosine = (xvi++)->quaternion_value.cosine (x.quaternion_value);
00186 *(ii++) += 1.5*cosine*cosine - 0.5;
00187 }
00188 break;
00189 default:
00190 x.undef_op();
00191 };
00192 }
|
|
||||||||||||||||||||
|
Optimized routine for the second order Legendre polynomial, (3cos^2(w)-1)/2, of one collective variable with an array.
Definition at line 110 of file colvarvalue.C. References check_types(), colvarmodule::fatal_error(), colvarmodule::rvector::norm(), quaternion_value, rvector_value, type_quaternion, type_scalar, type_unitvector, type_vector, undef_op(), and value_type. Referenced by colvar::calc_p2coor_acf(). 00114 {
00115 // doing type check only once, here
00116 colvarvalue::check_types (x, *xv);
00117
00118 std::vector<colvarvalue>::iterator &xvi = xv;
00119 std::vector<cvm::real>::iterator &ii = inner;
00120
00121 switch (x.value_type) {
00122 case colvarvalue::type_scalar:
00123 cvm::fatal_error ("Error: cannot calculate Legendre polynomials "
00124 "for scalar variables.\n");
00125 break;
00126 case colvarvalue::type_vector:
00127 while (xvi != xv_end) {
00128 cvm::real const cosine =
00129 ((xvi)->rvector_value * x.rvector_value) /
00130 ((xvi)->rvector_value.norm() * x.rvector_value.norm());
00131 xvi++;
00132 *(ii++) += 1.5*cosine*cosine - 0.5;
00133 }
00134 break;
00135 case colvarvalue::type_unitvector:
00136 while (xvi != xv_end) {
00137 cvm::real const cosine = (xvi++)->rvector_value * x.rvector_value;
00138 *(ii++) += 1.5*cosine*cosine - 0.5;
00139 }
00140 break;
00141 case colvarvalue::type_quaternion:
00142 while (xvi != xv_end) {
00143 cvm::real const cosine = (xvi++)->quaternion_value.cosine (x.quaternion_value);
00144 *(ii++) += 1.5*cosine*cosine - 0.5;
00145 }
00146 break;
00147 default:
00148 x.undef_op();
00149 };
00150 }
|
|
|
Set to the null value for the data type currently defined.
Definition at line 311 of file colvarvalue.h. References quaternion_value, colvarmodule::real, real_value, rvector_value, type_notset, type_quaternion, type_scalar, type_unitvector, and type_vector. Referenced by colvar::calc(), colvar::calc_runave(), colvar::reset_bias_force(), and colvar::update(). 00312 {
00313 switch (value_type) {
00314 case colvarvalue::type_scalar:
00315 real_value = cvm::real (0.0);
00316 break;
00317 case colvarvalue::type_vector:
00318 case colvarvalue::type_unitvector:
00319 rvector_value = cvm::rvector (0.0, 0.0, 0.0);
00320 break;
00321 case colvarvalue::type_quaternion:
00322 quaternion_value = cvm::quaternion (0.0, 0.0, 0.0, 0.0);
00323 break;
00324 case colvarvalue::type_notset:
00325 default:
00326 break;
00327 }
00328 }
|
|
|
Definition at line 190 of file colvarvalue.h. References value_type. 00191 {
00192 reset();
00193 value_type = x.value_type;
00194 reset();
00195 }
|
|
|
Set the type explicitly.
Definition at line 182 of file colvarvalue.h. 00183 {
00184 reset();
00185 value_type = vti;
00186 reset();
00187 }
|
|
|
|
Definition at line 97 of file colvarvalue.h. Referenced by dist2(), dist2_grad(), operator *(), operator+(), operator+=(), operator-(), and operator-=(). 00098 {
00099 return true;
00100 }
|
|
|
Undefined operation.
Definition at line 19 of file colvarvalue.C. References colvarmodule::fatal_error(), and type_desc. Referenced by dist2(), dist2_grad(), inner_opt(), inverse(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator=(), operator>>(), and p2leg_opt(). 00020 {
00021 cvm::fatal_error ("Error: Undefined operation on a colvar of type \""+
00022 colvarvalue::type_desc[this->value_type]+"\".\n");
00023 }
|
|
|
Initial value:
{ 0, 1, 3, 2, 3 }
Definition at line 15 of file colvarvalue.C. |
|
|
Quaternion data member.
Definition at line 92 of file colvarvalue.h. Referenced by apply_constraints(), colvar::orientation::apply_force(), colvar::orientation::calc_value(), colvarvalue(), dist2(), colvar::orientation::dist2(), dist2_grad(), colvar::orientation::dist2_lgrad(), colvar::orientation::dist2_rgrad(), inner_opt(), inverse(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator<<(), operator=(), operator>>(), p2leg_opt(), and reset(). |
|
|
|
|
Initial value:
{ "not_set",
"scalar number",
"3-dimensional vector",
"3-dimensional unit vector",
"4-dimensional unit vector" }
Definition at line 8 of file colvarvalue.C. Referenced by check_types(), and undef_op(). |
|
|
Current type of this colvarvalue object.
Definition at line 95 of file colvarvalue.h. Referenced by check_types(), colvarvalue(), inner_opt(), operator *(), operator+(), operator-(), operator/(), operator=(), p2leg_opt(), and type(). |
1.3.9.1