| version 1.14 | version 1.15 |
|---|
| |
| /// -*- c++ -*- | // -*- c++ -*- |
| | |
| #ifndef COLVARTYPES_H | #ifndef COLVARTYPES_H |
| #define COLVARTYPES_H | #define COLVARTYPES_H |
| |
| } | } |
| } | } |
| | |
| | /// Return a reference to the data |
| | inline std::vector<T> &data_array() |
| | { |
| | return data; |
| | } |
| | |
| inline ~vector1d() | inline ~vector1d() |
| { | { |
| data.clear(); | data.clear(); |
| |
| return std::sqrt(this->norm2()); | return std::sqrt(this->norm2()); |
| } | } |
| | |
| | inline cvm::real sum() const |
| | { |
| | cvm::real result = 0.0; |
| | size_t i; |
| | for (i = 0; i < this->size(); i++) { |
| | result += (*this)[i]; |
| | } |
| | return result; |
| | } |
| | |
| /// Slicing | /// Slicing |
| inline vector1d<T> const slice(size_t const i1, size_t const i2) const | inline vector1d<T> const slice(size_t const i1, size_t const i2) const |
| { | { |
| |
| { | { |
| std::stringstream stream(s); | std::stringstream stream(s); |
| size_t i = 0; | size_t i = 0; |
| | if (this->size()) { |
| while ((stream >> (*this)[i]) && (i < this->size())) { | while ((stream >> (*this)[i]) && (i < this->size())) { |
| i++; | i++; |
| } | } |
| if (i < this->size()) { | if (i < this->size()) { |
| return COLVARS_ERROR; | return COLVARS_ERROR; |
| } | } |
| | } else { |
| | T input; |
| | while (stream >> input) { |
| | if ((i % 100) == 0) { |
| | data.reserve(data.size()+100); |
| | } |
| | data.resize(data.size()+1); |
| | data[i] = input; |
| | i++; |
| | } |
| | } |
| return COLVARS_OK; | return COLVARS_OK; |
| } | } |
| | |
| |
| this->clear(); | this->clear(); |
| } | } |
| | |
| | /// Return a reference to the data |
| | inline std::vector<T> &data_array() |
| | { |
| | return data; |
| | } |
| | |
| inline row & operator [] (size_t const i) | inline row & operator [] (size_t const i) |
| { | { |
| return rows[i]; | return rows[i]; |