Changeset 9f2b6f in git for factory/templates/ftmpl_array.cc
- Timestamp:
- Jul 16, 1996, 2:24:57 PM (28 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 70161e0eb6f97b4a4008f8a9dee8629adf6bb83c
- Parents:
- b4e0579fccaa2c1ecd567dfc168f75ef1795e42c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/templates/ftmpl_array.cc
rb4e057 r9f2b6f 1 1 // emacs edit mode for this file is -*- C++ -*- 2 // $Id: ftmpl_array.cc,v 1. 0 1996-05-17 11:06:32stobbe Exp $2 // $Id: ftmpl_array.cc,v 1.1 1996-07-16 12:24:56 stobbe Exp $ 3 3 4 4 /* 5 5 $Log: not supported by cvs2svn $ 6 Revision 1.0 1996/05/17 11:06:32 stobbe 7 Initial revision 8 6 9 */ 7 10 … … 116 119 } 117 120 121 /* 118 122 template <class T> 119 123 Array<T>& Array<T>::operator*= ( const T & t ) … … 142 146 return *this; 143 147 } 148 */ 144 149 145 150 template <class T> … … 163 168 } 164 169 165 template <class T>166 T sum ( const Array<T> & a, int f, int l )167 {168 if ( f < a.min() ) f = a.min();169 if ( l > a.max() ) l = a.max();170 T s = 0;171 for ( int i = f; i <= l; i++ )172 s += a[i];173 return s;174 }175 176 template <class T>177 T prod ( const Array<T> & a, int f, int l )178 {179 if ( f < a.min() ) f = a.min();180 if ( l > a.max() ) l = a.max();181 T p = 1;182 for ( int i = f; i <= l; i++ )183 p *= a[i];184 return p;185 }186 187 template <class T>188 T sum ( const Array<T> & a )189 {190 return sum( a, a.min(), a.max() );191 }192 193 template <class T>194 T prod ( const Array<T> & a )195 {196 return prod( a, a.min(), a.max() );197 }198 199 200 template <class T>201 T crossprod ( const Array<T> & a, const Array<T> & b )202 {203 if ( a.size() != b.size() ) {204 cerr << "warning: array size mismatch." << endl;205 return 0;206 }207 T s = 0;208 int fa = a.min();209 int fb = b.min();210 int n = a.max();211 for ( ; fa <= n; fa++, fb++ )212 s += a[fa] * b[fb];213 return s;214 }
Note: See TracChangeset
for help on using the changeset viewer.