For overloaded operators involving vectors and matrices, see vec_arith.h . For statistics operations not included here, see vec_stats.h in the directory src/other . For functions and classes which are specific to C-style arrays, see array.h . Also related are the matrix output functions, matrix_out(), matrix_cx_out_paren(), and matrix_out_paren() which are defined in columnify.h because they utilize the class columnify to format the output.
Definition in file vector.h.
#include <iostream>
#include <cmath>
#include <string>
#include <fstream>
#include <sstream>
#include <o2scl/err_hnd.h>
#include <gsl/gsl_ieee_utils.h>
#include <gsl/gsl_sort.h>
Go to the source code of this file.
Functions | |
| template<class vec_t, class vec2_t> | |
| void | vector_copy (size_t N, vec_t &src, vec2_t &dest) |
| Naive vector copy. | |
| template<class mat_t, class mat2_t> | |
| void | matrix_copy (size_t M, size_t N, mat_t &src, mat2_t &dest) |
| Naive matrix copy. | |
| template<class vec_t, class vec2_t> | |
| void | vector_cx_copy_gsl (size_t N, vec_t &src, vec2_t &dest) |
| GSL complex vector copy. | |
| template<class mat_t, class mat2_t> | |
| void | matrix_cx_copy_gsl (size_t M, size_t N, mat_t &src, mat2_t &dest) |
| GSL complex matrix copy. | |
| template<class vec_t> | |
| int | vector_out (std::ostream &os, size_t n, vec_t &v, bool endline=false) |
| Output a vector to a stream. | |
| template<class data_t, class vec_t> | |
| void | sort_downheap (vec_t &data, const size_t N, size_t k) |
| Provide a downheap() function for vector_sort(). | |
| template<class data_t, class vec_t> | |
| int | vector_sort (const size_t n, vec_t &data) |
| Sort a vector. | |
| template<class data_t, class vec_t> | |
| int | vector_rotate (const size_t n, vec_t &data, size_t k) |
| "Rotate" a vector so that the kth element is now the beginning | |
| template<class vec_t> | |
| double | vector_max (const size_t n, vec_t &data) |
Compute the maximum of the first n elements of a vector. | |
| template<class vec_t> | |
| double | vector_min (const size_t n, vec_t &data) |
Compute the minimum of the first n elements of a vector. | |
| template<class vec_t> | |
| int | vector_minmax (const size_t n, vec_t &data, double &min, double &max) |
Compute the minimum and maximum of the first n elements of a vector. | |
| template<class vec_t> | |
| size_t | vector_max_index (const size_t n, vec_t &data, double &max) |
Compute the maximum of the first n elements of a vector. | |
| template<class vec_t> | |
| int | vector_min_index (const size_t n, vec_t &data, double &min) |
Compute the minimum of the first n elements of a vector. | |
| template<class vec_t> | |
| int | vector_minmax_index (const size_t n, vec_t &data, double &min, size_t &ix, double &max, size_t &ix2) |
Compute the minimum and maximum of the first n elements of a vector. | |
| template<class vec_t> | |
| double | vector_sum (const size_t n, vec_t &data) |
Compute the sum of the first n elements of a vector. | |
| template<class data_t, class vec_t> | |
| int | vector_reverse (const size_t n, vec_t &data) |
| Reverse a vector. | |
| void matrix_copy | ( | size_t | M, | |
| size_t | N, | |||
| mat_t & | src, | |||
| mat2_t & | dest | |||
| ) | [inline] |
Naive matrix copy.
gsl_matrix_memcpy . This is to be used with matrix_copy(N,source,destination);
gsl_matrix_memcpy(destination,source);
| void matrix_cx_copy_gsl | ( | size_t | M, | |
| size_t | N, | |||
| mat_t & | src, | |||
| mat2_t & | dest | |||
| ) | [inline] |
GSL complex matrix copy.
| void vector_copy | ( | size_t | N, | |
| vec_t & | src, | |||
| vec2_t & | dest | |||
| ) | [inline] |
Naive vector copy.
gsl_vector_memcpy . This is to be used with vector_copy(N,source,destination);
gsl_vector_memcpy(destination,source);
| void vector_cx_copy_gsl | ( | size_t | N, | |
| vec_t & | src, | |||
| vec2_t & | dest | |||
| ) | [inline] |
GSL complex vector copy.
| int vector_out | ( | std::ostream & | os, | |
| size_t | n, | |||
| vec_t & | v, | |||
| bool | endline = false | |||
| ) | [inline] |
Output a vector to a stream.
No trailing space is output after the last element, and an endline is output only if endline is set to true. If the parameter n is zero, this function silently does nothing.
Note that the O2scl vector classes also have their own operator<<() defined for them.
| int vector_rotate | ( | const size_t | n, | |
| vec_t & | data, | |||
| size_t | k | |||
| ) | [inline] |
| int vector_sort | ( | const size_t | n, | |
| vec_t & | data | |||
| ) | [inline] |
Sort a vector.
This is a generic sorting template function. It will work for any types data_t and vec_t for which
data_t has an operator=data_t has a less than operator to compare elementsvec_t::operator[] returns a reference to an object of type data_t
In particular, it will work with ovector, uvector, ovector_int, uvector_int (and other related O2scl vector classes), the STL template class std::vector, and arrays and pointers of numeric, character, and string objects.
For example,
std::string list[3]={"dog","cat","fox"};
vector_sort<std::string, std::string[3]>(3,list);
| double vector_sum | ( | const size_t | n, | |
| vec_t & | data | |||
| ) | [inline] |
Compute the sum of the first n elements of a vector.
If n is zero, this will set avg to zero and return gsl_success.
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page