Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

vnl_c_vector.h

Go to the documentation of this file.
00001 #ifndef vnl_c_vector_h_
00002 #define vnl_c_vector_h_
00003 // This is vxl/vnl/vnl_c_vector.h
00004 
00005 //: \file
00006 //  \brief Math on blocks of memory
00007 //  \author Andrew W. Fitzgibbon, Oxford RRG, 12 Feb 98
00008 //    vnl_c_vector interfaces to lowlevel memory-block operations.
00009 //
00010 
00011 // Modifications
00012 //     980212 AWF Initial version.
00013 //     LSB (Manchester) 26/3/01 Tidied documentation
00014 //
00015 //-----------------------------------------------------------------------------
00016 
00017 #include <vcl_iosfwd.h>
00018 #include <vnl/vnl_numeric_traits.h>
00019 
00020 // avoid messing about with aux_* functions for gcc 2.7 -- fsm
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 //: vnl_c_vector interfaces to lowlevel memory-block operations.
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 //: y[i]  = x[i]
00042   static void copy    (T const *x, T       *y, unsigned);     
00043   
00044 //:  y[i]  = a*x[i]
00045   static void scale   (T const *x, T       *y, unsigned, T const &); 
00046 
00047 //: z[i]  = x[i] + y[i];
00048   static void add     (T const *x, T const *y, T *z, unsigned); 
00049   
00050 //: z[i]  = x[i] - y[i]
00051   static void subtract(T const *x, T const *y, T *z, unsigned);   
00052   
00053 //: z[i]  = x[i] * y[i]
00054   static void multiply(T const *x, T const *y, T *z, unsigned); 
00055 
00056 //: z[i]  = x[i] / y[i]
00057   static void divide  (T const *x, T const *y, T *z, unsigned); 
00058   
00059 //: y[i]  = -x[i]
00060   static void negate  (T const *x, T       *y, unsigned); 
00061   
00062 //: y[i]  = 1/x[i]
00063   static void invert  (T const *x, T       *y, unsigned); 
00064   
00065  //:  y[i] += a*x[i]
00066   static void saxpy   (T const &a, T const *x, T *y, unsigned); 
00067   
00068 //: x[i]  = v
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 //: conjugate second
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   //:  one_norm : sum of abs values  
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   //: two_norm : sqrt of sum of squared abs values
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  //: inf_norm : max of abs values
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   //: two_nrm2 : sum of squared abs values
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   //: rms_norm : sqrt of mean sum of squared abs values
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   //: Memory allocation
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_

Generated at Fri May 21 01:15:46 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000