vector.h

Go to the documentation of this file.
00001 /* -----------------------------------------------------------------------------------------
00002   $Id: vector.h 571 2006-11-10 18:30:25Z svacek $
00003   $Author: svacek $
00004    ----------------------------------------------------------------------------------------- */
00005 #include <malloc.h>
00006 #include <stdlib.h>
00007 #include <stdio.h>
00008 #include <math.h>
00009 #include "wlog.h"
00010 #ifndef __VECTOR_SVH
00011 #define __VECTOR_SVH
00012 /* --------------------------------------------------------------------------------  */
00013 /*@{*/
00014 /** \defgroup VECTOR_OPS Vector Operations */
00015 /** \ingroup LINEAR_ALGEBRA */
00016 /* --------------------------------------------------------------------------------  */
00017 typedef struct
00018 {
00019   double *a;
00020   long n;
00021 } vector; /**< Vector of n-th DOUBLEs */
00022 
00023 void set_vec(vector *pom,double *a,long n);                                     /**< set link to memory to treat that as vector */
00024 void link_vec(vector *pom,const vector u);                                      /**< set link to memory of the vector u */
00025 void concat2_vec(vector *uv,const vector u,const vector v);                     /**< Concatenate 2 vectors */
00026 void concat3_vec(vector *uv,const vector u,const vector v,const vector w);      /**< Concatenate 3 vectors */
00027 void construct_vec(vector *u,long k);                                           /**< Creates vector u */
00028 void construct_vec_copy(vector *u,const vector v);                              /**< Creates copy of the vector v */
00029 void construct_vec_concat2(vector *uv,const vector u,const vector v);           /**< Construct Concatenation of  2 vectors */
00030 void construct_vec_concat3(vector *uv,const vector u,const vector v,const vector w);  /**< Construct Concatenation of 3 vectors */
00031 void destruct_vec(vector *which);                                               /**< Destruct the vector */
00032 void print_vec(const vector u,char *name);                                      /**< Destruct the vector */
00033 void split_vec(vector *out,const vector in,long start,long end);                /**< Take one part start..end of vector IN and puts it into (alloceted) OUT */
00034 /**< Computes the norm of vector U :
00035      - l1-norm (k=1), 
00036      - l2-norm(k=2),
00037      - l-\f$\infty\f$ norm(k=3) ) 
00038 */
00039 double norm_vec(const vector u,int k);
00040 /**< Computes the distance of vector u and v as \f$\|u-v\|_k\f$ :
00041      - l1-norm (k=1), 
00042      - l2-norm(k=2),
00043      - l-\f$\infty\f$ norm(k=3) ) 
00044 */
00045 double distance_vec(const vector u,const vector v,int k);
00046 void zeroize_vec(vector u);                                                     /**< Puts zero into vector */
00047 void load_vec(vector *u,const char *FileName);                                  /**< Load vector from (ASCII) file */
00048 void load_vec_bin(vector *u,const char *FileName);                              /**< Load vector from (BINARY) file */
00049 void save_vec(const vector u,const char *FileName);                             /**< Saves vector to (ASCII) file */
00050 void save_vec_bin(const vector u,const char *FileName);                         /**< Saves vector to (BINARY) file */
00051 void add_vec(vector u,const vector v);                                          /**< Makes u := u+v */
00052 void add_vec_val(vector u,double alpha);                                        /**< Makes u := u+alpha */
00053 void subtract_vec(vector u,const vector v);                                     /**< Makes u := u-v */
00054 void multiply_vec(vector u,double alpha);                                       /**< Makes u := u*alpha */
00055 double product_vec(const vector u,const vector v);                              /**< Returns dot product of \f$ u \cdot v = \sum_i u_i v_i \f$ */
00056 void dot_multiply_vec(vector which,const vector b);                             /**< Makes MATLAB operation componentwise multiple:  which(i)=which(i)*b(i) for all i */
00057 void lincomb_vec(vector u,const vector v,const double alpha,const double beta); /**< Linear combination u:= alpha * u + beta * v */
00058 void copy_vec(vector u,const vector v);                                         /**< Copy vector v to u , i.e. u:=v */
00059 int vec_isnan(vector u);
00060 /*@}*/
00061 
00062 #endif

Generated on Sun May 27 11:59:43 2007 for FEMFLUID by  doxygen 1.4.6