Ignore:
Timestamp:
Jul 16, 1996, 2:24:57 PM (28 years ago)
Author:
Rüdiger Stobbe <stobbe@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
70161e0eb6f97b4a4008f8a9dee8629adf6bb83c
Parents:
b4e0579fccaa2c1ecd567dfc168f75ef1795e42c
Message:
"operators += and *= deleted sincethey are not needed in an general
array class als well as the functions sum, prod, crossprod.
"


git-svn-id: file:///usr/local/Singular/svn/trunk@45 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/templates/ftmpl_array.cc

    rb4e057 r9f2b6f  
    11// emacs edit mode for this file is -*- C++ -*-
    2 // $Id: ftmpl_array.cc,v 1.0 1996-05-17 11:06:32 stobbe Exp $
     2// $Id: ftmpl_array.cc,v 1.1 1996-07-16 12:24:56 stobbe Exp $
    33
    44/*
    55$Log: not supported by cvs2svn $
     6Revision 1.0  1996/05/17 11:06:32  stobbe
     7Initial revision
     8
    69*/
    710
     
    116119}
    117120
     121/*
    118122template <class T>
    119123Array<T>& Array<T>::operator*= ( const T & t )
     
    142146    return *this;
    143147}
     148*/
    144149
    145150template <class T>
     
    163168}
    164169
    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.