Changeset 70161e in git for factory/fac_util.cc


Ignore:
Timestamp:
Jul 16, 1996, 2:26:05 PM (28 years ago)
Author:
Rüdiger Stobbe <stobbe@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
1251952559942e380e666f13188d81cd17e90569
Parents:
9f2b6f23a8e1f2de750bc3241e6e692d3f57c0d1
Message:
"New functions prod, crossprod ans sum for CFArrays, since these functions
are no longer contained in the template specification of Array.
"


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

Legend:

Unmodified
Added
Removed
  • factory/fac_util.cc

    r9f2b6f r70161e  
    11// emacs edit mode for this file is -*- C++ -*-
    2 // $Id: fac_util.cc,v 1.2 1996-07-08 08:22:02 stobbe Exp $
     2// $Id: fac_util.cc,v 1.3 1996-07-16 12:26:05 stobbe Exp $
    33
    44/*
    55$Log: not supported by cvs2svn $
     6Revision 1.2  1996/07/08 08:22:02  stobbe
     7"New organization of the factorization stuff. Some functions moved from
     8fac_diophand.cc which no longer exists.
     9"
     10
    611Revision 1.1  1996/06/27 11:34:24  stobbe
    712"New function dviremainder.
     
    213218}
    214219
     220CanonicalForm
     221sum ( const CFArray & a, int f, int l )
     222{
     223    if ( f < a.min() ) f = a.min();
     224    if ( l > a.max() ) l = a.max();
     225    CanonicalForm s = 0;
     226    for ( int i = f; i <= l; i++ )
     227        s += a[i];
     228    return s;
     229}
     230
     231CanonicalForm
     232prod ( const CFArray & a, int f, int l )
     233{
     234    if ( f < a.min() ) f = a.min();
     235    if ( l > a.max() ) l = a.max();
     236    CanonicalForm p = 1;
     237    for ( int i = f; i <= l; i++ )
     238        p *= a[i];
     239    return p;
     240}
     241
     242CanonicalForm
     243sum ( const CFArray & a )
     244{
     245    return sum( a, a.min(), a.max() );
     246}
     247
     248CanonicalForm
     249prod ( const CFArray & a )
     250{
     251    return prod( a, a.min(), a.max() );
     252}
     253
     254CanonicalForm
     255crossprod ( const CFArray & a, const CFArray & b )
     256{
     257    if ( a.size() != b.size() ) {
     258        cerr << "warning: array size mismatch." << endl;
     259        return 0;
     260    }
     261    CanonicalForm s = 0;
     262    int fa = a.min();
     263    int fb = b.min();
     264    int n = a.max();
     265    for ( ; fa <= n; fa++, fb++ )
     266        s += a[fa] * b[fb];
     267    return s;
     268}
Note: See TracChangeset for help on using the changeset viewer.