#include <colvartypes.h>
Public Member Functions | |
| size_t | size () |
| Length of the array. | |
| vector1d (T const &t=T()) | |
| Default constructor. | |
| void | reset () |
| Set all elements to zero. | |
| vector1d (T const *v) | |
| Constructor from a 1-d C array. | |
| vector1d (vector1d< T, length > const &v) | |
| Copy constructor. | |
| vector1d< T, length > & | operator= (vector1d< T, length > const &v) |
| Assignment. | |
| ~vector1d () | |
| Destructor. | |
| T * | c_array () |
| Return the 1-d C array. | |
| operator T * () | |
| Return the 1-d C array. | |
Protected Attributes | |
| T * | array |
| Underlying C-array. | |
Friends | |
| T | operator * (vector1d< T, length > const &v1, vector1d< T, length > const &v2) |
| Inner product. | |
| std::ostream & | operator<< (std::ostream &os, vector1d< T, length > const &v) |
| Formatted output. | |
Definition at line 172 of file colvartypes.h.
|
||||||||||
|
Default constructor.
Definition at line 188 of file colvartypes.h.
|
|
||||||||||
|
Constructor from a 1-d C array.
Definition at line 203 of file colvartypes.h. 00204 {
00205 array = new T[length];
00206 for (size_t i = 0; i < length; i++) {
00207 array[i] = v[i];
00208 }
00209 }
|
|
||||||||||
|
Copy constructor.
Definition at line 212 of file colvartypes.h. References colvarmodule::vector1d< T, length >::array. 00213 {
00214 array = new T[length];
00215 for (size_t i = 0; i < length; i++) {
00216 array[i] = v.array[i];
00217 }
00218 }
|
|
|||||||||
|
Destructor.
Definition at line 230 of file colvartypes.h. 00230 {
00231 delete [] array;
00232 }
|
|
|||||||||
|
Return the 1-d C array.
Definition at line 235 of file colvartypes.h. 00235 { return array; }
|
|
|||||||||
|
Return the 1-d C array.
Definition at line 238 of file colvartypes.h. 00238 { return array; }
|
|
||||||||||
|
Assignment.
Definition at line 221 of file colvartypes.h. References colvarmodule::vector1d< T, length >::array. 00222 {
00223 for (size_t i = 0; i < length; i++) {
00224 this->array[i] = v.array[i];
00225 }
00226 return *this;
00227 }
|
|
|||||||||
|
Set all elements to zero.
Definition at line 195 of file colvartypes.h. 00196 {
00197 for (size_t i = 0; i < length; i++) {
00198 array[i] = T (0.0);
00199 }
00200 }
|
|
|||||||||
|
Length of the array.
Definition at line 182 of file colvartypes.h. 00183 {
00184 return length;
00185 }
|
|
||||||||||||||||
|
Inner product.
Definition at line 241 of file colvartypes.h. 00243 {
00244 T prod (0.0);
00245 for (size_t i = 0; i < length; i++) {
00246 prod += v1.array[i] * v2.array[i];
00247 }
00248 return prod;
00249 }
|
|
||||||||||||||||
|
Formatted output.
Definition at line 252 of file colvartypes.h. 00254 {
00255 std::streamsize const w = os.width();
00256 std::streamsize const p = os.precision();
00257
00258 os << "( ";
00259 for (size_t i = 0; i < length-1; i++) {
00260 os.width (w); os.precision (p);
00261 os << v.array[i] << " , ";
00262 }
00263 os.width (w); os.precision (p);
00264 os << v.array[length-1] << " )";
00265 return os;
00266 }
|
|
|||||
|
Underlying C-array.
Definition at line 177 of file colvartypes.h. Referenced by colvarmodule::vector1d< T, length >::operator=(), and colvarmodule::vector1d< T, length >::vector1d(). |
1.3.9.1