Minsky
interpolateHypercube.h
Go to the documentation of this file.
1 /*
2  @copyright Russell Standish 2020
3  @author Russell Standish
4  This file is part of Civita.
5 
6  Civita is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Civita is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Civita. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef CIVITA_INTERPOLATE_HYPERCUBE_H
21 #define CIVITA_INTERPOLATE_HYPERCUBE_H
22 #include "tensorOp.h"
23 using namespace std;
24 
25 namespace civita
26 {
29  class InterpolateHC: public ITensor
30  {
33  Hypercube interimHC;
34  std::vector<std::size_t> strides;
35  std::vector<std::size_t> rotation;
36 
37  std::vector<std::pair<XVector, std::vector<std::size_t>>> sortedArgHC;
38  void sortAndAdd(const XVector&);
39 
40  //
41  vector<std::size_t> splitAndRotate(std::size_t) const;
42 
45  {
46  std::size_t index;
47  double weight;
48  WeightedIndex(std::size_t index,double weight): index(index), weight(weight) {}
49  };
50 
51  struct WeightedIndexVector: public vector<WeightedIndex>
52  {
53  bool argIsOnDestHypercube=false;
54  };
55 
57  vector<WeightedIndexVector> weightedIndices;
58 
61  WeightedIndexVector bodyCentredNeighbourhood(std::size_t idx) const;
62 
63  public:
64  void setArgument(const TensorPtr& a, const ITensor::Args& args={"",0}) override;
65  double operator[](std::size_t) const override;
66  Timestamp timestamp() const override {return arg? arg->timestamp(): Timestamp();}
67  };
68 
69 }
70 
71 #endif
std::vector< std::size_t > rotation
permutation of axes of interimHC and this->hypercube()
std::vector< std::size_t > strides
strides along each dimension of this->hypercube()
WeightedIndex(std::size_t index, double weight)
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
structure for referring to an argument index and its weight
STL namespace.
std::chrono::time_point< std::chrono::high_resolution_clock > Timestamp
vector< WeightedIndexVector > weightedIndices
map from this tensor&#39;s index into the argument tensor
arguments relevant for tensor expressions, not always meaningful. Exception thrown if not...
std::vector< std::pair< XVector, std::vector< std::size_t > > > sortedArgHC
std::shared_ptr< ITensor > TensorPtr
Hypercube interimHC
hypercube that&#39;s been rotated to match the arguments hypercube
Interpolates its argument to its hypercube rank must equal arg->rank(), and xvectors type must match...