2 #ifndef vnl_vector_fixed_ref_h_ 3 #define vnl_vector_fixed_ref_h_ 24 # include <vcl_msvc_warnings.h> 26 #include "vnl/vnl_export.h" 28 template <
class T,
unsigned int n>
52 unsigned size()
const {
return n; }
55 T
get (
unsigned int i)
const {
return data_[i]; }
67 T
const & operator() (
unsigned int i)
const 69 #if VNL_CONFIG_CHECK_BOUNDS && (!defined NDEBUG) 77 const T& operator[] (
unsigned int i )
const {
return data_[i]; }
132 vnl_vector<T> extract (
unsigned int len,
unsigned int start=0)
const;
187 void assert_size(
unsigned )
const { }
194 assert_finite_internal();
199 bool is_finite()
const;
202 bool is_zero()
const;
210 if ( (*
this)[i] !=
v[i] )
217 assert(
v.size() == n );
219 if ( (*
this)[i] !=
v[i] )
227 void print( std::ostream& s )
const;
233 inline static void add(
const T* a,
const T* b, T* r ) {
234 for (
unsigned int i=0; i < n; ++i,++r,++a,++b )
238 inline static void add(
const T* a, T b, T* r ) {
239 for (
unsigned int i=0; i < n; ++i,++r,++a )
243 inline static void sub(
const T* a,
const T* b, T* r ) {
244 for (
unsigned int i=0; i < n; ++i,++r,++a,++b )
248 inline static void sub(
const T* a, T b, T* r ) {
249 for (
unsigned int i=0; i < n; ++i,++r,++a )
253 inline static void sub( T a,
const T* b, T* r ) {
254 for (
unsigned int i=0; i < n; ++i,++r,++b )
258 inline static void mul(
const T* a,
const T* b, T* r ) {
259 for (
unsigned int i=0; i < n; ++i,++r,++a,++b )
263 inline static void mul(
const T* a, T b, T* r ) {
264 for (
unsigned int i=0; i < n; ++i,++r,++a )
268 inline static void div(
const T* a,
const T* b, T* r ) {
269 for (
unsigned int i=0; i < n; ++i,++r,++a,++b )
273 inline static void div(
const T* a, T b, T* r ) {
274 for (
unsigned int i=0; i < n; ++i,++r,++a )
289 assert(!
"Assignment is illegal for a vnl_vector_fixed_ref_const");
294 assert(!
"Assignment is illegal for a vnl_vector_fixed_ref_const");
297 void assert_finite_internal()
const;
302 template <
class T,
unsigned n>
312 T *
data_block()
const {
return const_cast<T*>(this->data_); }
363 #if VNL_CONFIG_CHECK_BOUNDS && (!defined NDEBUG) 386 bool read_ascii(std::istream& s)
const;
422 assert(
v.size() == n );
428 assert(
v.size() == n );
442 template<
class T,
unsigned int n>
451 template<
class T,
unsigned int n>
460 template<
class T,
unsigned int n>
469 template<
class T,
unsigned int n>
478 template<
class T,
unsigned int n>
487 template<
class T,
unsigned int n>
496 template<
class T,
unsigned int n>
509 template<
class T,
unsigned int n>
518 template<
class T,
unsigned int n>
526 template<
class T,
unsigned int n>
534 template<
class T,
unsigned int n>
547 result[0] = v1[1] * v2[2] - v1[2] * v2[1];
548 result[1] = v1[2] * v2[0] - v1[0] * v2[2];
549 result[2] = v1[0] * v2[1] - v1[1] * v2[0];
557 template<
class T,
unsigned int n>
563 template<
class T,
unsigned int n>
569 template<
class T,
unsigned int n>
575 template<
class T,
unsigned int n>
582 template<
class T,
unsigned n>
588 template<
class T,
unsigned n>
594 template<
class T,
unsigned n>
600 template<
class T,
unsigned int m,
unsigned int n>
604 for (
unsigned int i = 0; i <
m; i++)
605 for (
unsigned int j = 0; j < n; j++)
606 out[i][j] = a[i] * b[j];
610 template<
class T,
unsigned int n>
615 template<
class T,
unsigned int n>
620 template<
class T,
unsigned int n>
626 template<
class T,
unsigned int n>
632 template<
class T,
unsigned n>
638 template<
class T,
unsigned n>
644 template<
class T,
unsigned n>
651 template<
class T,
unsigned n>
657 template<
class T,
unsigned n>
663 template<
class T,
unsigned n>
674 template<
class T,
unsigned int n>
683 template<
class T,
unsigned int n>
692 #endif // vnl_vector_fixed_ref_h_ const vnl_vector_fixed_ref_const< T, n > & operator=(const vnl_vector_fixed_ref_const< T, n > &) const
static void sub(T a, const T *b, T *r)
static void mul(const T *a, const T *b, T *r)
const_iterator begin() const
Iterator pointing to start of data.
vnl_vector_fixed< T, n > element_quotient(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
vnl_vector_fixed_ref_const< T, n > base
iterator end() const
Iterator pointing to element beyond end of data.
vnl_bignum operator+(vnl_bignum const &r1, long r2)
Returns the sum of two bignum numbers.
T get(unsigned int i) const
Get value at element i.
vnl_vector_fixed_ref< T, n > const & operator+=(const vnl_vector_fixed< T, n > &v) const
const T * data_block() const
T vnl_vector_ssd(vnl_vector< T > const &v1, vnl_vector< T > const &v2)
Euclidean Distance between two vectors.
vnl_vector< T > as_vector() const
Convert to a vnl_vector.
T max_value() const
Largest value.
vnl_vector_fixed< T, n > operator-() const
vnl_vector_fixed_ref< T, n > const & operator-=(T s) const
vnl_vector_fixed_ref(T *dataptr)
static unsigned arg_min(T const *, unsigned)
Returns location of min value of the vector.
void assert_finite() const
Check that this is finite if not, abort();.
vnl_vector_ref< T > as_ref()
vnl_vector using user-supplied storage.
abs_t inf_norm() const
Return largest absolute element value.
vnl_vector_fixed_ref< T, n > const & operator=(const vnl_vector_fixed_ref_const< T, n > &rhs) const
Copy operator.
vnl_vector_fixed_ref< T, n > const & operator/=(T s) const
vnl_vector_fixed_ref< T, n > const & operator+=(const vnl_vector< T > &v) const
static T sum(T const *v, unsigned n)
vnl_vector_fixed_ref< T, n > const & operator=(const vnl_vector_fixed< T, n > &rhs) const
Copy operator.
vnl_vector_fixed< T, n > element_product(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
static void add(const T *a, const T *b, T *r)
static abs_t rms_norm(T const *p, unsigned n)
rms_norm : sqrt of mean sum of squared abs values.
iterator begin() const
Iterator pointing to start of data.
void add(const vnl_bignum &b1, const vnl_bignum &b2, vnl_bignum &sum)
add two non-infinite vnl_bignum values and save their sum.
static void div(const T *a, const T *b, T *r)
Fixed size, stack-stored, space-efficient matrix.
T const & operator()(unsigned int i) const
Return reference to the element at specified index.
bool operator==(vnl_vector_fixed_ref_const< T, n > const &that) const
Equality operator.
T const * const_iterator
Const iterator type.
vnl_vector_fixed_ref(vnl_vector_fixed< T, n > &rhs)
vnl_c_vector< T >::abs_t abs_t
T const * iterator
Type defs for iterators.
const T & operator[](unsigned int i) const
Return the i-th element.
vnl_vector_fixed_ref const & copy_in(T const *ptr) const
Sets elements to ptr[i].
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.
vnl_vector_fixed_ref< T, n > const & operator+=(T s) const
static void sub(const T *a, const T *b, T *r)
std::ostream & operator<<(std::ostream &s, vnl_decnum const &r)
decimal output.
static void add(const T *a, T b, T *r)
const_iterator end() const
Iterator pointing to element beyond end of data.
void put(unsigned int i, T const &v) const
Put value at given position in vector.
static unsigned arg_max(T const *, unsigned)
Returns location of max value of the vector.
static T min_value(T const *, unsigned)
Returns min value of the vector.
An ordinary mathematical matrix.
static T mean(T const *p, unsigned n)
unsigned arg_min() const
Location of smallest value.
static void mul(const T *a, T b, T *r)
T const * data_block() const
Access the contiguous block storing the elements in the vector.
unsigned size() const
Length of the vector.
T min_value() const
Smallest value.
vnl_vector_fixed_ref_const(vnl_vector_fixed< T, n > const &rhs)
T dot_product(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
T mean() const
Mean of values in vector.
bool operator_eq(vnl_vector< T > const &v) const
Return true if *this == v.
vnl_numeric_traits< T >::abs_t abs_t
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)
bool operator!=(vnl_vector_fixed_ref_const< T, n > const &that) const
Inequality operator.
vnl_vector_fixed_ref< T, n > const & operator=(const vnl_vector_fixed_ref< T, n > &rhs) const
Copy operator.
Fixed length stack-stored, space-efficient vector.
Fixed length stack-stored vector.
abs_t one_norm() const
Return sum of absolute values of the elements.
abs_t rms() const
Root Mean Squares of values.
void assert_size(unsigned sz) const
Check that size()==sz if not, abort();.
vnl_vector_fixed_ref< T, n > const & operator-=(const vnl_vector< T > &v) const
vnl_vector_fixed_ref & fill(T const &v)
Set all values to v.
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.
static T max_value(T const *, unsigned)
Returns max value of the vector.
abs_t squared_magnitude() const
Return sum of squares of elements.
vnl_vector_fixed_ref const & set(T const *ptr) const
Sets elements to ptr[i].
abs_t two_norm() const
Return sqrt of sum of squares of values of elements.
static void add(const T *a, const T *b, T *r)
vnl_vector_fixed_ref_const(const T *dataptr)
static void sub(const T *a, T b, T *r)
vnl_vector_fixed_ref< T, n > const & operator-=(const vnl_vector_fixed< T, n > &v) const
bool empty() const
Return true iff the size is zero.
bool operator_eq(vnl_vector_fixed_ref_const< T, n > const &v) const
Return true if *this == v.
T sum() const
Sum of values in a vector.
unsigned arg_max() const
Location of largest value.
vnl_bignum operator/(vnl_bignum const &r1, vnl_bignum const &r2)
Returns the division of two bignum numbers.
abs_t magnitude() const
Return magnitude (length) of vector.
vnl_vector_fixed_ref_const(const vnl_vector_fixed_ref_const< T, n > &rhs)
const vnl_vector_fixed_ref_const< T, n > & operator=(const vnl_vector_fixed< T, n > &) const
See assert_finite().
vnl_bignum operator *(vnl_bignum const &r1, vnl_bignum const &r2)
Returns the product of two bignum numbers.
static abs_t two_nrm2(T const *p, unsigned n)
two_nrm2 : sum of squared abs values.
static void mul(const T *a, const T *b, T *r)
T element_type
Type defs for iterators.
static abs_t inf_norm(T const *p, unsigned n)
inf_norm : max of abs values.
void copy_out(T *ptr) const
Copy elements to ptr[i].
static void sub(const T *a, const T *b, T *r)
const vnl_vector_ref< T > as_ref() const
Explicit conversion to a vnl_vector_ref.
vnl_vector< T > vnl_cross_3d(const vnl_vector< T > &v1, const vnl_vector< T > &v2)
Compute the 3-D cross product.
static void div(const T *a, const T *b, T *r)
static void div(const T *a, T b, T *r)