This file contains the alloction classes
For output of matrices rather than vectors, see matrix_out() and related functions documented in columnify.h.
Note that the classes
Definition in file array.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.
Data Structures | |
class | array_alloc |
A simple class to provide an allocate() function for arrays. More... | |
class | array_2d_alloc |
A simple class to provide an allocate() function for 2-dimensional arrays. More... | |
class | pointer_alloc |
A simple class to provide an allocate() function for pointers. More... | |
class | pointer_2d_alloc |
A simple class to provide an allocate() function for pointers. More... | |
class | array_reverse |
A simple class which reverses the order of an array. More... | |
class | array_const_reverse |
A simple class which reverses the order of an array. More... | |
class | array_subvector |
A simple subvector class for an array (without error checking). More... | |
class | array_const_subvector |
A simple subvector class for a const array (without error checking). More... | |
class | array_subvector_reverse |
Reverse a subvector of an array. More... | |
class | array_const_subvector_reverse |
Reverse a subvector of a const array. More... | |
class | array_row |
Extract a row of a C-style 2d-array. More... | |
Functions | |
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 data_t, class vec_t> | |
int | vector_max (const size_t n, vec_t &data, data_t &max, size_t &ix) |
Compute the maximum of the first n elements of a vector. | |
template<class data_t, class vec_t> | |
int | vector_min (const size_t n, vec_t &data, data_t &min, size_t &ix) |
Compute the minimum of the first n elements of a vector. | |
template<class data_t, class vec_t> | |
int | vector_sum (const size_t n, vec_t &data, data_t &sum) |
Compute the sum of the first n elements of a vector. | |
template<class data_t, class vec_t> | |
int | vector_avg (const size_t n, vec_t &data, data_t &avg) |
Compute the mean of the first n elements of a vector. | |
template<class data_t, class vec_t> | |
int | vector_variance (const size_t n, vec_t &data, data_t &mean, data_t &var) |
Compute the variance of the first n elements of a vector given the mean mean . | |
template<class data_t, class vec_t> | |
int | vector_reverse (const size_t n, vec_t &data) |
Reverse a vector. | |
template<class data_t, class vec_t> | |
int | vector_stdev (const size_t n, vec_t &data, data_t &var) |
Compute the standard deviation of the first n elements of a vector. |
int vector_avg | ( | const size_t | n, | |
vec_t & | data, | |||
data_t & | avg | |||
) | [inline] |
Compute the mean of the first n
elements of a vector.
If n
is zero, this will set avg
to zero and return gsl_success.
int vector_out | ( | std::ostream & | os, | |
size_t | n, | |||
vec_t & | v, | |||
bool | endline = false | |||
) | [inline] |
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);
int vector_sum | ( | const size_t | n, | |
vec_t & | data, | |||
data_t & | sum | |||
) | [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.
int vector_variance | ( | const size_t | n, | |
vec_t & | data, | |||
data_t & | mean, | |||
data_t & | var | |||
) | [inline] |
Compute the variance of the first n
elements of a vector given the mean mean
.
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