9 #ifndef CT_VEC_FUNCTIONS_H
10 #define CT_VEC_FUNCTIONS_H
32 inline void copyn(
size_t n,
const T& x, T& y)
35 std::copy(x.begin(), x.begin() + n, y.begin());
51 std::transform(x.begin(), x.end(), y.begin(),
52 x.begin(), std::divides<typename T::value_type>());
69 std::transform(x.begin(), x.end(), y.begin(),
70 x.begin(), std::multiplies<typename T::value_type>());
82 template<
class T,
class S>
83 inline void scale(T& x, S scale_factor)
86 scale(x.begin(), x.end(), x.begin(), scale_factor);
102 return std::inner_product(x.begin(), x.end(), y.begin(), 0.0);
118 return _dot_ratio(x.begin(), x.end(), y.begin(), 0.0);
134 std::transform(x.begin(), x.end(), y.begin(),
135 x.begin(), std::plus<typename T::value_type>());
157 template<
class InputIter,
class S>
158 inline doublereal
_dot_ratio(InputIter x_begin, InputIter x_end,
159 InputIter y_begin, S start_value)
162 for (; x_begin != x_end; ++x_begin, ++y_begin) {
163 start_value += *x_begin / *y_begin;
182 for (
int i = 0; i < n; i++) {
183 maxval = std::max(std::abs(v[i]), maxval);
190 inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
193 for (
size_t i = 0; i < n; i++) {
doublereal _dot_ratio(InputIter x_begin, InputIter x_end, InputIter y_begin, S start_value)
Templated dot ratio class.
void divide_each(OutputIter x_begin, OutputIter x_end, InputIter y_begin)
Templated divide of each element of x by the corresponding element of y.
void add_each(T &x, const T &y)
Returns a templated addition operation of two objects.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
void multiply_each(OutputIter x_begin, OutputIter x_end, InputIter y_begin)
Multiply each entry in x by the corresponding entry in y.
doublereal absmax(InputIter begin, InputIter end)
The maximum absolute value (templated version)
void copyn(size_t n, const T &x, T &y)
Templated function that copies the first n entries from x to y.
doublereal dot_ratio(const T &x, const T &y)
Returns the templated dot ratio of two objects.
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
doublereal dot_product(const T &x, const T &y)
Return the templated dot product of two objects.