Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Path: gap4r8 / pkg / NormalizInterface-1.0.2 / Normaliz.git / Qsource / libQnormaliz / Qsublattice_representation.h
Views: 418384/*1* Normaliz2* Copyright (C) 2007-2014 Winfried Bruns, Bogdan Ichim, Christof Soeger3* This program is free software: you can redistribute it and/or modify4* it under the terms of the GNU General Public License as published by5* the Free Software Foundation, either version 3 of the License, or6* (at your option) any later version.7*8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License14* along with this program. If not, see <http://www.gnu.org/licenses/>.15*16* As an exception, when this program is distributed through (i) the App Store17* by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or (iii) Google Play18* by Google Inc., then that store may impose any digital rights management,19* device limits and/or redistribution restrictions that are required by its20* terms of service.21*/2223/**24* The class Sublattice_Representation represents a sublattice of Z^n as Z^r.25* To transform vectors of the sublattice use:26* Z^r --> Z^n and Z^n --> Z^r27* v |-> vA u |-> (uB)/c28* A r x n matrix29* B n x r matrix30* c Number31*/3233#ifndef SUBLATTICE_REPRESENTATION_H34#define SUBLATTICE_REPRESENTATION_H3536#include <vector>37#include <libQnormaliz/libQnormaliz.h>38#include <libQnormaliz/Qmatrix.h>3940//---------------------------------------------------------------------------4142namespace libQnormaliz {4344template<typename Number> class Matrix;45// template<typename Number> class Lineare_Transformation;46using std::vector;474849template<typename Number>50class Sublattice_Representation {5152template<typename> friend class Sublattice_Representation;5354size_t dim, rank;55bool is_identity;56Matrix<Number> A;57Matrix<Number> B;58Number c;59mutable mpz_class external_index;60mutable Matrix<Number> Equations;61mutable bool Equations_computed;6263void make_equations() const;6465//---------------------------------------------------------------------------66public:67//---------------------------------------------------------------------------68// Construction and destruction69//---------------------------------------------------------------------------7071/**72* creates a dummy object73*/74Sublattice_Representation() {}7576/**77* creates a representation of Z^n as a sublattice of itself78*/79Sublattice_Representation(size_t n);8081/**82* Main Constructor83* creates a representation of a sublattice of Z^n84* if direct_summand is false the sublattice is generated by the rows of M85* otherwise it is a direct summand of Z^n containing the rows of M86*/87Sublattice_Representation(const Matrix<Number>& M, bool take_saturation); // take_saturation irrelevent8889template<typename NumberFC>90Sublattice_Representation(const Sublattice_Representation<NumberFC>& Original);91//---------------------------------------------------------------------------92// Manipulation operations93//---------------------------------------------------------------------------9495/* computes the coordinate transformations */96void initialize(const Matrix<Number>& M);9798/* first this then SR when going from Z^n to Z^r */99void compose(const Sublattice_Representation<Number>& SR);100101/* compose with the dual of SR */102void compose_dual(const Sublattice_Representation<Number>& SR);103104//---------------------------------------------------------------------------105// Transformations106//---------------------------------------------------------------------------107108Matrix<Number> to_sublattice (const Matrix<Number>& M) const;109Matrix<Number> from_sublattice (const Matrix<Number>& M) const;110Matrix<Number> to_sublattice_dual (const Matrix<Number>& M) const;111Matrix<Number> from_sublattice_dual (const Matrix<Number>& M) const;112113vector<Number> to_sublattice (const vector<Number>& V) const;114vector<Number> from_sublattice (const vector<Number>& V) const;115vector<Number> to_sublattice_dual (const vector<Number>& M) const;116vector<Number> from_sublattice_dual (const vector<Number>& V) const;117118vector<Number> to_sublattice_dual_no_div (const vector<Number>& M) const;119120// and with integrated type conversion121// Note: the "to" conversions assume that val has the same integer type as the SLR122// whereas the "from" versions assume that ret has the same integer type as the SLR.123template<typename ToType, typename FromType>124void convert_to_sublattice(ToType& ret, const FromType& val) const {125convert(ret, to_sublattice(val));126}127128template<typename ToType>129void convert_to_sublattice(Matrix<ToType>& ret, const Matrix<Number> & val) const {130ret=Matrix<ToType>(val.nr_of_rows(),rank);131vector<Number> v;132for(size_t i=0;i<val.nr_of_rows();++i){133v=to_sublattice(val[i]);134convert(ret[i],v);135}136}137138template<typename ToType, typename FromType>139void convert_from_sublattice(ToType& ret, const FromType& val) const {140ret = from_sublattice(convertTo<ToType>(val));141}142143template<typename FromType>144void convert_from_sublattice(Matrix<Number>& ret, const Matrix<FromType> & val) const {145ret=Matrix<Number>(val.nr_of_rows(),dim);146vector<Number> v;147for(size_t i=0;i<val.nr_of_rows();++i){148convert(v,val[i]);149ret[i]=from_sublattice(v);150}151}152153template<typename ToType, typename FromType>154void convert_to_sublattice_dual(ToType& ret, const FromType& val) const {155convert(ret, to_sublattice_dual(val));156}157158template<typename ToType>159void convert_to_sublattice_dual(Matrix<ToType>& ret, const Matrix<Number> & val) const {160ret=Matrix<ToType>(val.nr_of_rows(),rank);161vector<Number> v;162for(size_t i=0;i<val.nr_of_rows();++i){163v=to_sublattice_dual(val[i]);164convert(ret[i],v);165}166}167168template<typename ToType, typename FromType>169void convert_from_sublattice_dual(ToType& ret, const FromType& val) const {170ret = from_sublattice_dual(convertTo<ToType>(val));171}172173template<typename FromType>174void convert_from_sublattice_dual(Matrix<Number>& ret, const Matrix<FromType> & val) const {175ret=Matrix<Number>(val.nr_of_rows(),dim);176vector<Number> v;177for(size_t i=0;i<val.nr_of_rows();++i){178convert(v,val[i]);179ret[i]=from_sublattice_dual(v);180}181}182183template<typename ToType, typename FromType>184void convert_to_sublattice_dual_no_div(ToType& ret, const FromType& val) const {185convert(ret, to_sublattice_dual_no_div(val));186}187188template<typename ToType>189void convert_to_sublattice_dual_no_div(Matrix<ToType>& ret, const Matrix<Number> & val) const {190ret=Matrix<ToType>(val.nr_of_rows(),rank);191vector<Number> v;192for(size_t i=0;i<val.nr_of_rows();++i){193v=to_sublattice_dual_no_div(val[i]);194convert(ret[i],v);195}196}197198199//---------------------------------------------------------------------------200// Data acces201//---------------------------------------------------------------------------202203/* returns the dimension of the ambient space */204size_t getDim() const;205206/* returns the rank of the sublattice */207size_t getRank() const;208209Number getAnnihilator() const;210bool IsIdentity()const;211212const Matrix<Number>& getEquationsMatrix() const;213const vector<vector<Number> >& getEquations() const;214mpz_class getExternalIndex() const;215const Matrix<Number>& getEmbeddingMatrix() const;216const vector<vector<Number> >& getEmbedding() const;217const Matrix<Number>& getProjectionMatrix() const;218const vector<vector<Number> >& getProjection() const;219220};221222}223224//---------------------------------------------------------------------------225#endif226//---------------------------------------------------------------------------227228229