Macaulay2 Engine
Loading...
Searching...
No Matches
SLP.cpp
Go to the documentation of this file.
1// Copyright 2015 Anton Leykin and Mike Stillman
2
3#include "SLP.hpp"
4
5// SLProgram
7{
8 // std::cerr << "in SLProgram::SLProgram" << std::endl;
9 inputCounter = 0;
10}
11
13{
14 // std::cerr << "~SLProgram" << std::endl;
15}
16
18{
19 mNodes.push_back(MSum);
20 mNumInputs.push_back(a->len);
21 for (int i = 0; i < a->len; i++)
22 mInputPositions.push_back(a->array[i] -
23 static_cast<GATE_POSITION>(mNodes.size()) + 1);
24 return static_cast<GATE_POSITION>(mNodes.size()) - 1;
25}
27{
28 mNodes.push_back(MProduct);
29 mNumInputs.push_back(a->len);
30 for (int i = 0; i < a->len; i++)
31 mInputPositions.push_back(a->array[i] -
32 static_cast<GATE_POSITION>(mNodes.size()) + 1);
33 return static_cast<GATE_POSITION>(mNodes.size()) - 1;
34}
36{
37 mNodes.push_back(Det);
38 mNumInputs.push_back(a->len);
39 for (int i = 0; i < a->len; i++)
40 mInputPositions.push_back(a->array[i] -
41 static_cast<GATE_POSITION>(mNodes.size()) + 1);
42 return static_cast<GATE_POSITION>(mNodes.size()) - 1;
43}
45{
46 mNodes.push_back(Divide);
47 if (a->len != 2) ERROR("Divide expected two arguments");
48 for (int i = 0; i < 2; i++)
49 mInputPositions.push_back(a->array[i] -
50 static_cast<GATE_POSITION>(mNodes.size()) + 1);
51 return static_cast<GATE_POSITION>(mNodes.size()) - 1;
52}
54{
55 for (int i = 0; i < a->len; i++)
56 {
57 int p = a->array[i];
59 ERROR("input or constant position out of range");
60 else if (p >= 0 && p >= mNodes.size())
61 ERROR("node position out of range");
62 else
63 mOutputPositions.push_back(p);
64 }
65}
66
68{
69 o << "SLProgram (" << newline;
70 o << " consts+vars: " << inputCounter << newline;
71 o << " noninput nodes: " << mNodes.size() << newline;
72 o << " output nodes: " << mOutputPositions.size() << newline;
73 o << " )" << newline;
74}
75
76// Local Variables:
77// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
78// indent-tabs-mode: nil
79// End:
Public umbrella header for the templated straight-line-program evaluator (SLProgram / SLEvaluatorConc...
std::vector< GATE_POSITION > mInputPositions
Definition SLP-defs.hpp:98
GATE_POSITION addMProduct(const M2_arrayint)
Definition SLP.cpp:26
int GATE_POSITION
Definition SLP-defs.hpp:93
GATE_POSITION addDet(const M2_arrayint)
Definition SLP.cpp:35
int inputCounter
Definition SLP-defs.hpp:107
void text_out(buffer &) const
Definition SLP.cpp:67
SLProgram()
Definition SLP.cpp:6
GATE_POSITION addDivide(const M2_arrayint)
Definition SLP.cpp:44
void setOutputPositions(const M2_arrayint)
Definition SLP.cpp:53
virtual ~SLProgram()
Definition SLP.cpp:12
std::vector< GATE_SIZE > mNumInputs
Definition SLP-defs.hpp:96
GATE_POSITION addMSum(const M2_arrayint)
Definition SLP.cpp:17
std::vector< GATE_TYPE > mNodes
Definition SLP-defs.hpp:95
std::vector< GATE_POSITION > mOutputPositions
Definition SLP-defs.hpp:103
int p
const int ERROR
Definition m2-mem.cpp:55
char newline[]
Definition m2-types.cpp:49