source: git/factory/cf_eval.cc @ 16f511

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