1 #ifndef __cxx_test_project_vector_h__ 2 #define __cxx_test_project_vector_h__ 17 template<
typename Scalar>
39 assert((1 <= i) && (i <=
size));
41 return *(
values + (i - 1)); }
46 {
return *(
values + (i - 1)); }
68 template <
typename OUTPUT_STREAM>
70 const unsigned int precision = 3,
71 const bool scientific =
true,
72 const unsigned int width_ = 0,
73 const char *zero_string =
"*",
74 const double denominator = 1.,
75 const double threshold = 0.)
const 77 unsigned int width = width_;
79 os <<
"Vector of length " <<
size << std::endl;
83 std::ios::fmtflags old_flags = os.flags();
84 unsigned int old_precision = os.precision (precision);
87 os.setf (std::ios::scientific, std::ios::floatfield);
92 os.setf (std::ios::fixed, std::ios::floatfield);
97 for (
int i1 = 1 ; i1 <=
size; i1++) {
98 if (std::fabs((*
this)(i1)) > threshold)
99 os << std::setw(width)
100 << (*this)(i1) * Scalar(denominator) <<
' ';
102 os << std::setw(width) << zero_string <<
' ';
107 os.flags (old_flags);
108 os.precision(old_precision);
Namespace for core components.
Scalar * get_values()
get the array of elements of the vector
Scalar & operator()(int i)
access and change individual elements
Vector(int _size)
constructor of a vector of size _size
Scalar * values
the entries of the vector
int get_size() const
get the number of entries
virtual ~Vector()
destructor, delete memory created during construction
void print_formatted(OUTPUT_STREAM &os, const unsigned int precision=3, const bool scientific=true, const unsigned int width_=0, const char *zero_string="*", const double denominator=1., const double threshold=0.) const
print the matrix in some nice form
Scalar operator()(int i) const
access individual element
A vector of arbitrary size.
const Scalar * get_values() const
get the array of elements of the vector