1 // Copyright 2017 Steven Diamond 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Some useful defines for Matricies/etc. 16 17 #ifndef UTILS_H 18 #define UTILS_H 19 20 #include "../include/Eigen/Core" 21 #include "../include/Eigen/Sparse" 22 23 #define NULL_MATRIX Eigen::SparseMatrix<double>(0, 0) 24 25 typedef Eigen::Matrix<int, Eigen::Dynamic, 1> Vector; 26 typedef Eigen::SparseMatrix<double> Matrix; 27 typedef std::map<int, Matrix> CoeffMap; 28 typedef Eigen::Triplet<double> Triplet; 29 typedef std::map<int, std::map<int, std::vector<Matrix> > > Tensor; 30 typedef std::map<int, std::vector<Matrix> > DictMat; 31 32 /* ID for all things of CONSTANT_TYPE */ 33 static const int CONSTANT_ID = -1; 34 35 int vecprod(const std::vector<int> &vec); 36 int vecprod_before(const std::vector<int> &vec, int end); 37 Tensor tensor_mul(const Tensor &lh_ten, const Tensor &rh_ten); 38 void acc_tensor(Tensor &lh_ten, const Tensor &rh_ten); 39 Matrix diagonalize(const Matrix &mat); 40 41 #endif 42