00001 #ifndef vnl_c_vector_h_
00002 #define vnl_c_vector_h_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <vcl_iosfwd.h>
00018 #include <vnl/vnl_numeric_traits.h>
00019
00020
00021 template <class T, class S> void vnl_c_vector_one_norm(T const *p, unsigned n, S *out);
00022 template <class T, class S> void vnl_c_vector_two_norm(T const *p, unsigned n, S *out);
00023 template <class T, class S> void vnl_c_vector_inf_norm(T const *p, unsigned n, S *out);
00024 template <class T, class S> void vnl_c_vector_two_norm_squared(T const *p, unsigned n, S *out);
00025 template <class T, class S> void vnl_c_vector_rms_norm(T const *p, unsigned n, S *out);
00026
00027
00028 export template <class T>
00029 class vnl_c_vector {
00030 public:
00031 typedef typename vnl_numeric_traits<T>::abs_t abs_t;
00032
00033 static T sum(const T* v, unsigned n);
00034 static inline abs_t squared_magnitude(T const *p, unsigned n)
00035 { abs_t val; vnl_c_vector_two_norm_squared(p, n, &val); return val; }
00036 static void normalize(T *, unsigned n);
00037 static void apply(T const *, unsigned, T (*f)(T), T* v_out);
00038 static void apply(T const *, unsigned, T (*f)(const T&), T* v_out);
00039
00040
00041
00042 static void copy (T const *x, T *y, unsigned);
00043
00044
00045 static void scale (T const *x, T *y, unsigned, T const &);
00046
00047
00048 static void add (T const *x, T const *y, T *z, unsigned);
00049
00050
00051 static void subtract(T const *x, T const *y, T *z, unsigned);
00052
00053
00054 static void multiply(T const *x, T const *y, T *z, unsigned);
00055
00056
00057 static void divide (T const *x, T const *y, T *z, unsigned);
00058
00059
00060 static void negate (T const *x, T *y, unsigned);
00061
00062
00063 static void invert (T const *x, T *y, unsigned);
00064
00065
00066 static void saxpy (T const &a, T const *x, T *y, unsigned);
00067
00068
00069 static void fill (T *x, unsigned, T const &v);
00070
00071
00072 static void reverse (T *x, unsigned);
00073 static T dot_product (T const *, T const *, unsigned);
00074
00075
00076 static T inner_product(T const *, T const *, unsigned);
00077 static void conjugate(T const *, T *, unsigned);
00078
00079 static T max_value(T const *, unsigned);
00080 static T min_value(T const *, unsigned);
00081 static T mean(T const *p, unsigned n) { return sum(p,n)/T(n); }
00082
00083
00084
00085 static inline abs_t one_norm(T const *p, unsigned n)
00086 { abs_t val; vnl_c_vector_one_norm(p, n, &val); return val; }
00087
00088
00089 static inline abs_t two_norm(T const *p, unsigned n)
00090 { abs_t val; vnl_c_vector_two_norm(p, n, &val); return val; }
00091
00092
00093 static inline abs_t inf_norm(T const *p, unsigned n)
00094 { abs_t val; vnl_c_vector_inf_norm(p, n, &val); return val; }
00095
00096
00097 static inline abs_t two_nrm2(T const *p, unsigned n)
00098 { abs_t val; vnl_c_vector_two_norm_squared(p, n, &val); return val; }
00099
00100
00101 static inline abs_t rms_norm(T const *p, unsigned n)
00102 { abs_t val; vnl_c_vector_rms_norm(p, n, &val); return val; }
00103
00104
00105 static T** allocate_Tptr(int n);
00106 static T* allocate_T(int n);
00107 static void deallocate(T**, int n_when_allocated);
00108 static void deallocate(T*, int n_when_allocated);
00109 };
00110
00111 #endif // vnl_c_vector_h_