44template <
class R >
class SVectorBase;
45template <
class R >
class SSVectorBase;
126 val.assign(p_val, p_val + dimen);
137 template <
typename S>
164 for(
auto& v :
vec.val)
198 assert(
dim() ==
vec.dim());
202 for(
decltype(dimen) i = 0 ; i < dimen; i++)
215 assert(
dim() ==
vec.dim());
221 for(
decltype(dimen) i = 0; i < dimen; i++)
228 for(
decltype(dimen) i = 0; i < dimen; i++)
272 return int(
val.size());
278 assert(n >= 0 && n <
dim());
285 assert(n >= 0 && n <
dim());
292 return (vec1.
val == vec2.
val);
296 const std::vector<R>&
vec()
318 assert(
dim() ==
vec.dim());
322 for(
decltype(dimen) i = 0; i < dimen; i++)
340 assert(
dim() ==
vec.dim());
344 for(
decltype(dimen) i = 0; i < dimen; i++)
365 for(
decltype(dimen) i = 0; i < dimen; i++)
379 for(
decltype(dimen) i = 0; i < dimen; i++)
392 for(
decltype(dimen) i = 0; i < dimen; i++)
410 auto absCmpr = [](R a, R b)
415 auto maxReference = std::max_element(
val.begin(),
val.end(), absCmpr);
417 R maxi =
spxAbs(*maxReference);
430 auto absCmpr = [](R a, R b)
435 auto minReference = SOPLEX_MIN_element(
val.begin(),
val.end(), absCmpr);
437 R mini =
spxAbs(*minReference);
453 return (*
this) * (*this);
457 template <
class S,
class T >
460 assert(
vec.dim() ==
dim());
464 for(
decltype(dimen) i = 0; i < dimen; i++)
471 template <
class S,
class T >
475 template <
class S,
class T >
479 template <
class S,
class T >
509 typename std::vector<R>::const_iterator
begin()
const
514 typename std::vector<R>::iterator
begin()
520 typename std::vector<R>::const_iterator
end()
const
525 typename std::vector<R>::iterator
end()
537 return int(
val.capacity());
541 void reDim(
int newdim,
const bool setZero =
true)
543 if(setZero && newdim >
dim())
567 val.reserve(newsize);
573 assert(
vec.dim() ==
dim());
579 for(
decltype(dimen) i = 0; i < dimen; i++)
596 for(
decltype(dimen) i = 0; i < dimen; i++)
598 res.
val.push_back(
val[i] + v[i]);
609 res.
val.reserve(
vec.dim());
611 for(
auto& v :
vec.val)
613 res.
val.push_back(-(v));
634 assert(vec.
dim() == dim());
636 if(dim() <= 0 || vec.
dim() <= 0)
644 for(
decltype(dimen) i = 1; i < dimen; i++)
645 x += val[i] * vec.
val[i];
R * get_ptr()
Conversion to C-style pointer.
VectorBase< R > & operator+=(const VectorBase< S > &vec)
Addition.
R minAbs() const
Minimum absolute value.
VectorBase< R > & assign(const SVectorBase< S > &vec)
Assign values of vec.
VectorBase< R > & operator=(const VectorBase< S > &vec)
Assignment operator.
R length() const
Floating point approximation of euclidian norm (without any approximation guarantee).
R length2() const
Squared norm.
std::vector< R >::const_iterator end() const
R maxAbs() const
Maximum absolute value, i.e., infinity norm.
bool isConsistent() const
Consistency check.
std::vector< R >::iterator end()
VectorBase< R > & scaleAssign(const int *scaleExp, const VectorBase< R > &vec, bool negateExp=false)
scale and assign
VectorBase(const VectorBase< R > &vec)
VectorBase< R > & operator-=(const VectorBase< S > &vec)
Subtraction.
const VectorBase< R > operator-(const VectorBase< R > &vec) const
VectorBase< R > & operator*=(const S &x)
Scaling.
const R & operator[](int n) const
Return n 'th value.
VectorBase< R > & operator=(const VectorBase< R > &vec)
Assignment operator.
std::vector< R >::iterator begin()
void reDim(int newdim, const bool setZero=true)
Resets VectorBase's dimension to newdim.
VectorBase(int dimen, R *p_val)
VectorBase< R > & operator=(const VectorBase< R > &&vec)
Move assignment operator.
VectorBase(const VectorBase< R > &&vec) noexcept
int dim() const
Dimension of vector.
friend VectorBase< R > operator-(const VectorBase< R > &vec)
std::vector< R > val
Values of vector.
VectorBase< R > & scaleAssign(int scaleExp, const VectorBase< R > &vec)
scale and assign
void reSize(int newsize)
Resets VectorBase's memory size to newsize.
VectorBase< R > & operator/=(const S &x)
Division.
const std::vector< R > & vec()
Return underlying std::vector.
R & operator[](int n)
Return n 'th value by reference.
void clear()
Set vector to contain all-zeros (keeping the same length)
VectorBase< R > & multSub(const S &x, const SVectorBase< T > &vec)
Subtraction of scaled vector.
friend bool operator==(const VectorBase< R > &vec1, const VectorBase< R > &vec2)
Equality operator.
R operator*(const VectorBase< R > &vec) const
Inner product.
const R * get_const_ptr() const
Conversion to C-style pointer.
const VectorBase< R > operator+(const VectorBase< R > &v) const
std::vector< R >::const_iterator begin() const
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
VectorBase(const VectorBase< S > &vec)
Everything should be within this namespace.
number< gmp_rational, et_off > Rational
Real spxSqrt(Real a)
returns square root
boost::multiprecision::number< T > spxLdexp(boost::multiprecision::number< T, eto > x, int exp)
Debugging, floating point type and parameter definitions.