-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode.hpp
67 lines (49 loc) · 1.38 KB
/
node.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Copyright 2020 Casey Sanchez
*/
#pragma once
#include <iostream>
#include <string>
#include <complex>
#include <memory>
#include <vector>
#include <map>
#include <variant>
#include <algorithm>
#include <numeric>
#include "utils.hpp"
class Node;
using Scalar = std::shared_ptr<Node>;
class Node
{
protected:
std::complex<double> m_value;
std::vector<Scalar> m_arguments;
public:
Node(std::complex<double> const &value = 0.0);
Node(std::initializer_list<Scalar> const &arguments);
Scalar &Argument(size_t const &index);
Scalar Argument(size_t const &index) const;
std::vector<Scalar> &Arguments();
std::vector<Scalar> Arguments() const;
virtual std::string Type() const;
virtual std::complex<double> Value() const;
public:
static bool Equivalent(Scalar const &lhs_ptr, Scalar const &rhs_ptr);
friend std::ostream &operator<<(std::ostream &ostream, Node const &node);
friend std::ostream &operator<<(std::ostream &ostream, Scalar const &scalar);
};
class VariableNode : public Node
{
public:
VariableNode(std::complex<double> const &value = 0.0);
std::string Type() const override;
Node &operator=(std::complex<double> const &value);
};
class ConstantNode : public Node
{
public:
ConstantNode(std::complex<double> const &value);
std::string Type() const override;
Node &operator=(Node const &node) = delete;
};