18 #include <vcl_compiler.h> 20 # include <vcl_msvc_warnings.h> 24 #include <vnl/vnl_config.h> 26 #include "vnl/vnl_export.h" 28 # if VNL_CONFIG_CHECK_BOUNDS 32 # undef VNL_CONFIG_CHECK_BOUNDS 33 # define VNL_CONFIG_CHECK_BOUNDS 0 34 # undef ERROR_CHECKING 42 #define v vnl_vector<T> 43 #define m vnl_matrix<T> 44 template <
class T> VNL_EXPORT T
dot_product(
v const&,
v const&);
46 template <
class T> VNL_EXPORT T
bracket(
v const &,
m const &,
v const &);
47 template <
class T> VNL_EXPORT T
cos_angle(
v const&,
v const& );
48 template <
class T> VNL_EXPORT
double angle(
v const&,
v const&);
50 template <
class T> VNL_EXPORT
v operator+(T,
v const&);
51 template <
class T> VNL_EXPORT
v operator-(T,
v const&);
52 template <
class T> VNL_EXPORT
v operator*(T,
v const&);
54 template <
class T> VNL_EXPORT
v operator*(
v const&,
m const&);
58 template <
class T> VNL_EXPORT
void swap(
v &,
v &);
90 vnl_vector(
size_t len,
size_t n, T
const values[]);
99 #ifndef VXL_DOXYGEN_SHOULD_SKIP_THIS 112 : num_elmts(that.num_elmts),
data(that.
data)
118 #ifdef __INTEL_COMPILER 119 #pragma warning disable 444 //destructor for base class "itk::Array<>" is not virtual 126 size_t size()
const {
return this->num_elmts; }
129 inline void put(
size_t i, T
const&
v);
132 inline T
get(
size_t i)
const;
153 #if VNL_CONFIG_CHECK_BOUNDS 162 #if VNL_CONFIG_CHECK_BOUNDS 417 #if VNL_CONFIG_CHECK_BOUNDS 418 if (i >= this->
size())
421 return this->
data[i];
431 #if VNL_CONFIG_CHECK_BOUNDS 432 if (i >= this->
size())
498 #endif // vnl_vector_h_ vnl_matrix< T > & operator=(T const &v)
Set all elements to value v.
vnl_vector_fixed< T, n > element_quotient(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
bool is_zero() const
Return true if all elements equal to zero.
vnl_vector< T > operator/(T v) const
vnl_vector< T > & operator=(T const &v)
Set all elements to value v.
vnl_bignum operator+(vnl_bignum const &r1, long r2)
Returns the sum of two bignum numbers.
T min_value() const
Smallest value.
vnl_matrix & copy_in(T const *)
Fills (laminates) this matrix with the given data, then returns it.
vnl_vector< T > & operator-=(T value)
Subtract scalar value from all elements.
T vnl_vector_ssd(vnl_vector< T > const &v1, vnl_vector< T > const &v2)
Euclidean Distance between two vectors.
abs_t rms() const
Root Mean Squares of values.
vnl_vector< T > operator-(vnl_vector< T > const &v) const
static unsigned arg_min(T const *, unsigned)
Returns location of min value of the vector.
vnl_matrix< T > & operator+=(T value)
Add rhs to each element of lhs matrix in situ.
T element_type
Type defs for iterators.
vnl_vector< T > operator+(T v) const
vnl_matrix< T > extract(unsigned r, unsigned c, unsigned top=0, unsigned left=0) const
Extract a sub-matrix of size r x c, starting at (top,left).
VNL_EXPORT void swap(v &, v &)
void assert_size(size_t VXL_USED_IN_DEBUG(sz)) const
Check that size()==sz if not, abort();.
const_iterator end() const
Iterator pointing to element beyond end of data.
VNL_EXPORT T bracket(v const &, m const &, v const &)
static T sum(T const *v, unsigned n)
const_iterator begin() const
Iterator pointing to start of data.
T & operator()(size_t i)
Return reference to the element at specified index.
vnl_vector_fixed< T, n > element_product(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
size_t size() const
Return the length, number of elements, dimension of this vector.
T const * data_block() const
Access the contiguous block storing the elements in the vector. O(1).
static abs_t rms_norm(T const *p, unsigned n)
rms_norm : sqrt of mean sum of squared abs values.
VNL_EXPORT T cos_angle(v const &, v const &)
vnl_matrix< T > & operator *=(T value)
Scalar multiplication in situ of lhs matrix by rhs.
T sum() const
Sum of values in a vector.
iterator begin()
Iterator pointing to start of data.
abs_t magnitude() const
Return magnitude (length) of vector.
VNL_EXPORT T inner_product(v const &, v const &)
static abs_t one_norm(T const *p, unsigned n)
one_norm : sum of abs values.
static abs_t two_norm(T const *p, unsigned n)
two_norm : sqrt of sum of squared abs values.
abs_t squared_magnitude() const
Return sum of squares of elements.
iterator end()
Iterator pointing to element beyond end of data.
std::ostream & operator<<(std::ostream &s, vnl_decnum const &r)
decimal output.
T get(unsigned r, unsigned c) const
get element with boundary checks if error checking is on.
vnl_matrix< T > & operator-=(T value)
Subtract rhs from each element of lhs matrix in situ.
void vnl_error_vector_dimension(char const *fcn, int l1, int l2)
Raise exception for invalid dimension.
vnl_vector()
Creates an empty vector. O(1).
T max_value() const
Largest value.
T const & operator()(size_t i) const
Return reference to the element at specified index. No range checking.
void assert_size_internal(unsigned r, unsigned c) const
Abort unless M has the given size.
abs_t one_norm() const
Return sum of absolute values of the elements.
static unsigned arg_max(T const *, unsigned)
Returns location of max value of the vector.
iterator begin()
Iterator pointing to start of data.
void assert_finite_internal() const
Abort if any element of M is inf or nan.
static T min_value(T const *, unsigned)
Returns min value of the vector.
vnl_matrix< T > & operator/=(T value)
Scalar division of lhs matrix in situ by rhs.
An ordinary mathematical matrix.
static T mean(T const *p, unsigned n)
void clear()
Make the matrix as if it had been default-constructed.
vnl_matrix & fill(T const &)
Sets all elements of matrix to specified value, and returns "*this".
void swap(vnl_vector< T > &that)
Set this to that and that to this.
size_t arg_min() const
Location of smallest value.
vnl_vector< T > const & as_ref() const
Return a reference to this.
void put(size_t i, T const &v)
Put value at given position in vector.
T dot_product(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
vnl_vector(vnl_vector< T > &that, vnl_tag_grab)
T const & operator[](size_t i) const
Return reference to the element at specified index. No range checking.
VNL_EXPORT v operator *(T, v const &)
vnl_vector< T > operator+(vnl_vector< T > const &v) const
void assert_finite() const
Check that this is finite if not, abort();.
vnl_numeric_traits< T >::abs_t abs_t
void swap(vnl_matrix< T > &A, vnl_matrix< T > &B)
Swap two matrices.
Mathematical vector class, templated by type of element.
VNL_EXPORT vnl_matrix_fixed< T, m, n > outer_product(vnl_vector_fixed< T, m > const &a, vnl_vector_fixed< T, n > const &b)
T const * const_iterator
Const iterator type.
T const * data_block() const
Access the contiguous block storing the elements in the matrix row-wise. O(1).
T mean() const
Mean of values in vector.
vnl_vector< T > operator-(T v) const
bool operator_eq(vnl_matrix< T > const &rhs) const
Return true if *this == rhs.
static T euclid_dist_sq(T const *, T const *, unsigned)
Euclidean Distance between two vectors.
static void normalize(T *, unsigned n)
vnl_vector< T > & as_ref()
Return a reference to this.
static vnl_matrix< T > read(std::istream &s)
Read a vnl_matrix from an ascii std::istream, automatically determining file size if the input matrix...
T * iterator
Type defs for iterators.
unsigned int size() const
Return the total number of elements stored by the matrix.
void destroy()
Delete data.
bool is_equal(vnl_matrix< T > const &rhs, double tol) const
Return true if all elements of both matrices are equal, within given tolerance.
T angle(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
VNL_EXPORT std::istream & operator>>(std::istream &s, vnl_decnum &r)
decimal input.
vnl_bignum operator-(vnl_bignum const &r1, vnl_bignum const &r2)
Returns the difference of two bignum numbers.
size_t arg_max() const
Location of largest value.
abs_t inf_norm() const
Return largest absolute element value.
vnl_vector & set(T const *ptr)
Sets elements to ptr[i].
void vnl_error_vector_index(char const *fcn, int index)
Raise exception for invalid index.
static T max_value(T const *, unsigned)
Returns max value of the vector.
vnl_matrix< T > apply(T(*f)(T)) const
Make a new matrix by applying function to each element.
bool is_finite() const
Return true if finite.
T * data_block()
Access the contiguous block storing the elements in the vector. O(1).
vnl_c_vector< T >::abs_t abs_t
abs_t two_norm() const
Return sqrt of sum of squares of values of elements.
vnl_vector< T > & normalize()
Normalise by dividing through by the magnitude.
bool operator!=(vnl_vector< T > const &that) const
Inequality test.
bool set_size(unsigned r, unsigned c)
Resize to r rows by c columns. Old data lost.
bool read_ascii(std::istream &s)
Read a vnl_matrix from an ascii std::istream.
void copy_out(T *) const
Fills the given array with this matrix.
vnl_matrix< T > & update(vnl_matrix< T > const &, unsigned top=0, unsigned left=0)
Set values of this matrix to those of M, starting at [top,left].
vnl_bignum operator *(vnl_bignum const &r1, vnl_bignum const &r2)
Returns the product of two bignum numbers.
VNL_EXPORT v operator-(T, v const &)
T get(size_t i) const
Get value at element i.
static abs_t two_nrm2(T const *p, unsigned n)
two_nrm2 : sum of squared abs values.
Math on blocks of memory.
bool operator==(vnl_vector< T > const &that) const
Equality test.
static abs_t inf_norm(T const *p, unsigned n)
inf_norm : max of abs values.
vnl_vector< T > operator+() const
Unary plus operator.
bool empty() const
Return true iff the size is zero.
void put(unsigned r, unsigned c, T const &)
set element with boundary checks if error checking is on.
T & operator[](size_t i)
Return reference to the element at specified index. No range checking.