source: git/factory/cf_eval.cc @ 6ce030f

spielwiese
Last change on this file since 6ce030f was 362fc67, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: remove $Id$
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#include "config.h"
4
5#include "cf_assert.h"
6
7#include "cf_defs.h"
8#include "cf_eval.h"
9
10static CanonicalForm evalCF ( const CanonicalForm & f, const CFArray & a, int m, int n );
11
12
13Evaluation& Evaluation::operator= ( const Evaluation & e )
14{
15    if ( this != &e ) {
16        values = e.values;
17    }
18    return *this;
19}
20
21CanonicalForm
22Evaluation::operator() ( const CanonicalForm & f ) const
23{
24    if ( f.inCoeffDomain() || f.level() < values.min() )
25        return f;
26    else  if ( f.level() < values.max() )
27        return evalCF( f, values, values.min(), f.level() );
28    else
29        return evalCF( f, values, values.min(), values.max() );
30}
31
32CanonicalForm
33Evaluation::operator() ( const CanonicalForm & f, int i, int j ) const
34{
35    if ( i > j )
36        return f;
37    return evalCF( f, values, i, j );
38}
39
40void
41Evaluation::nextpoint()
42{
43    int n = values.max();
44    for ( int i = values.min(); i <= n; i++ )
45        values[i] += 1;
46}
47
48void
49Evaluation::setValue(int i, const CanonicalForm& f)
50{
51  if (i < values.min() || i > values.max())
52    return;
53  values[i]= f;
54}
55
56#ifndef NOSTREAMIO
57OSTREAM&
58operator<< ( OSTREAM& s, const Evaluation &e )
59{
60    e.values.print(s);
61    return s;
62}
63#endif /* NOSTREAMIO */
64
65CanonicalForm
66evalCF ( const CanonicalForm & f, const CFArray & a, int m, int n )
67{
68    if ( m > n )
69        return f;
70    else {
71        CanonicalForm result = f;
72        while ( n >= m ) {
73            result = result( a[n], Variable( n ) );
74            n--;
75        }
76        return result;
77    }
78//    iterated method turned out to be faster than
79//    return evalCF( f( a[n], Variable( n ) ), a, m, n-1 );
80}
Note: See TracBrowser for help on using the repository browser.