15 #ifndef included_Vector_h
16 #define included_Vector_h
18 #include "utils/Utilities.h"
69 bool copy_data =
true);
150 transform(std::function<
void(
const int size,
double* vector)> transformer);
163 std::function<
void(
const int size,
double* vector)> transformer)
const;
176 std::function<
void(
const int size,
double* vector)> transformer)
const;
189 std::function<
void(
const int size,
double* origVector,
double* resultVector)>
204 std::function<
void(
const int size,
double* origVector,
double* resultVector)>
219 std::function<
void(
const int size,
double* origVector,
double* resultVector)>
234 if (
dim > d_alloc_size) {
236 CAROM_ERROR(
"Can not reallocate externally owned storage.");
243 d_vec =
new double [
dim] {0.0};
257 return d_distributed;
285 const Vector& other)
const;
302 const Vector* other)
const
304 CAROM_VERIFY(other != 0);
350 const Vector& other)
const
370 const Vector* other)
const
372 CAROM_VERIFY(other != 0);
429 plusAx(factor, other, result);
450 CAROM_VERIFY(other != 0);
451 return plusAx(factor, *other);
522 CAROM_VERIFY(other != 0);
539 const Vector& other)
const
542 minus(other, result);
560 const Vector* other)
const
562 CAROM_VERIFY(other != 0);
563 return minus(*other);
614 mult(factor, result);
659 CAROM_ASSERT((0 <= i) && (i <
dim()));
678 CAROM_ASSERT((0 <= i) && (i <
dim()));
718 void print(
const char * prefix)
const;
726 void write(
const std::string& base_file_name);
734 void read(
const std::string& base_file_name);
743 void local_read(
const std::string& base_file_name,
int rank);
double * getData() const
Get the vector data as a pointer.
void setSize(int dim)
Sets the length of the vector and reallocates storage if needed. All values are initialized to zero.
double & item(int i)
Non-const Vector member access.
Vector * mult(double factor) const
Multiplies this by the supplied constant and returns the result.
void read(const std::string &base_file_name)
read Vector from (a) HDF file(s).
const double & operator()(int i) const
Const Vector member access.
Vector & operator-=(const Vector &rhs)
Subtraction operator.
Vector * plusAx(double factor, const Vector *other)
Adds factor*other and this and returns the result, pointer version.
bool distributed() const
Returns true if the Vector is distributed.
void plusEqAx(double factor, const Vector *other)
Adds factor*other to this, pointer version.
void print(const char *prefix) const
print Vector into (a) ascii file(s).
void distribute(const int local_dim)
Distribute this vector among MPI processes, based on the specified local dimension....
double inner_product(const Vector *other) const
Inner product, pointer version.
double norm() const
Form the norm of this.
Vector * minus(const Vector &other) const
Subtracts other and this and returns the result, reference version.
double normalize()
Normalizes the Vector and returns its norm.
void write(const std::string &base_file_name)
write Vector into (a) HDF file(s).
Vector * plus(const Vector &other) const
Adds other and this and returns the result, reference version.
const double & item(int i) const
Const Vector member access.
Vector * minus(const Vector *other) const
Subtracts other and this and returns the result, pointer version.
Vector & operator=(const Vector &rhs)
Assignment operator.
double inner_product(const Vector &other) const
Inner product, reference form.
void plusEqAx(double factor, const Vector &other)
Adds factor*other to this, reference version.
double norm2() const
Form the squared norm of this.
Vector * plusAx(double factor, const Vector &other)
Adds factor*other and this and returns the result, reference version.
Vector & transform(std::function< void(const int size, double *vector)> transformer)
Transform the vector using a supplied function.
Vector & operator+=(const Vector &rhs)
Addition operator.
double localMin(int nmax=0)
Compute the local minimum of this.
void local_read(const std::string &base_file_name, int rank)
read read a single rank of a distributed Vector from (a) HDF file(s).
int dim() const
Returns the dimension of the Vector on this processor.
Vector & operator*=(const double &a)
Scaling operator.
void gather()
Gather all the distributed elements among MPI processes. This becomes not distributed after this func...
Vector * plus(const Vector *other) const
Adds other and this and returns the result, pointer version.
int getClosestPoint(std::vector< Vector * > &points, Vector *test_point)
Get closest point to a test point among a group of points.
int getCenterPoint(std::vector< Vector * > &points, bool use_centroid)
Get center point of a group of points.