#ifndef MIXVOPS_INCLUDED // -*- C++ -*- #define MIXVOPS_INCLUDED // #endif // WARNING: Multiple inclusions allowed /************************************************************************ Low-level vector math operations. This header file is intended for internal library use only. You should understand what's going on in here before trying to use it yourself. Using the magic __LINKAGE macro, this file can be compiled either as a set of templated functions, or as a series of inline functions whose argument type is determined by the __T macro. My rationale for this is that some compilers either don't support templated functions or are incapable of inlining them. PUBLIC APOLOGY: I really do apologize for the ugliness of the code in this header. In order to accommodate various types of compilation and to avoid lots of typing, I've made pretty heavy use of macros. Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. $Id: mixvops.h,v 1.10 1998/10/26 21:09:40 garland Exp $ ************************************************************************/ #ifdef MX_DEFAULT_DIM # define __DIM const int N=MX_DEFAULT_DIM #else # define __DIM const int N #endif #if !defined(MIXVOPS_USE_TEMPLATES) # ifndef __T # define __T double # endif # define __LINKAGE inline #else # ifdef __T # undef __T # endif # define __LINKAGE templateinline #endif #define __OP __LINKAGE __T * #define forall(i, N) for(unsigned int i=0; i> v[i]; return in; } __LINKAGE istream& mxv_read(__T *v, __DIM) { return mxv_read(cin, v, N); } #ifndef mxv_local_block #ifdef __GNUC__ # define mxv_local_block(a,T,N) T a[N] # define mxv_free_local(a) #else # ifdef HAVE_ALLOCA # include # define mxv_local_block(a,T,N) T *a = (T *)alloca(sizeof(T)*N) # define mxv_free_local(a) # else # define mxv_local_block(a,T,N) T *a = new T[N] # define mxv_free_local(a) delete[] a # endif #endif #endif #undef __T #undef __DIM #undef __LINKAGE #undef __OP #undef forall #undef def3 #undef def2 #undef def1 #undef def2s #undef def1s // MIXVOPS_INCLUDED