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 / DST / include / libnormaliz / sublattice_representation.h
Views: 418427/*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 Integer31*/3233#ifndef SUBLATTICE_REPRESENTATION_H34#define SUBLATTICE_REPRESENTATION_H3536#include <vector>37#include <libnormaliz/libnormaliz.h>38#include <libnormaliz/matrix.h>3940//---------------------------------------------------------------------------4142namespace libnormaliz {4344template<typename Integer> class Matrix;45// template<typename Integer> class Lineare_Transformation;46using std::vector;474849template<typename Integer>50class Sublattice_Representation {5152template<typename> friend class Sublattice_Representation;5354size_t dim, rank;55bool is_identity;56Matrix<Integer> A;57Matrix<Integer> B;58Integer c;59mutable mpz_class external_index;60mutable Matrix<Integer> Equations;61mutable bool Equations_computed;62mutable Matrix<Integer> Congruences;63mutable bool Congruences_computed;6465void make_equations() const;66void make_congruences() const;6768//---------------------------------------------------------------------------69public:70//---------------------------------------------------------------------------71// Construction and destruction72//---------------------------------------------------------------------------7374/**75* creates a dummy object76*/77Sublattice_Representation() {}7879/**80* creates a representation of Z^n as a sublattice of itself81*/82Sublattice_Representation(size_t n);8384/**85* Main Constructor86* creates a representation of a sublattice of Z^n87* if direct_summand is false the sublattice is generated by the rows of M88* otherwise it is a direct summand of Z^n containing the rows of M89*/90Sublattice_Representation(const Matrix<Integer>& M, bool take_saturation);91// Sublattice_Representation(const Lineare_Transformation<Integer>& LT, bool take_saturation);9293template<typename IntegerFC>94Sublattice_Representation(const Sublattice_Representation<IntegerFC>& Original);95//---------------------------------------------------------------------------96// Manipulation operations97//---------------------------------------------------------------------------9899/* like the matching constructor */100void initialize(const Matrix<Integer>& M, bool take_saturation, bool& success);101102/* first this then SR when going from Z^n to Z^r */103void compose(const Sublattice_Representation<Integer>& SR);104105/* compose with the dual of SR */106void compose_dual(const Sublattice_Representation<Integer>& SR);107108//---------------------------------------------------------------------------109// Transformations110//---------------------------------------------------------------------------111112Matrix<Integer> to_sublattice (const Matrix<Integer>& M) const;113Matrix<Integer> from_sublattice (const Matrix<Integer>& M) const;114Matrix<Integer> to_sublattice_dual (const Matrix<Integer>& M) const;115Matrix<Integer> from_sublattice_dual (const Matrix<Integer>& M) const;116117vector<Integer> to_sublattice (const vector<Integer>& V) const;118vector<Integer> from_sublattice (const vector<Integer>& V) const;119vector<Integer> to_sublattice_dual (const vector<Integer>& M) const;120vector<Integer> from_sublattice_dual (const vector<Integer>& V) const;121122vector<Integer> to_sublattice_dual_no_div (const vector<Integer>& M) const;123124// and with integrated type conversion125// Note: the "to" conversions assume that val has the same integer type as the SLR126// whereas the "from" versions assume that ret has the same integer type as the SLR.127template<typename ToType, typename FromType>128void convert_to_sublattice(ToType& ret, const FromType& val) const {129convert(ret, to_sublattice(val));130}131132template<typename ToType>133void convert_to_sublattice(Matrix<ToType>& ret, const Matrix<Integer> & val) const {134ret=Matrix<ToType>(val.nr_of_rows(),rank);135vector<Integer> v;136for(size_t i=0;i<val.nr_of_rows();++i){137v=to_sublattice(val[i]);138convert(ret[i],v);139}140}141142template<typename ToType, typename FromType>143void convert_from_sublattice(ToType& ret, const FromType& val) const {144ret = from_sublattice(convertTo<ToType>(val));145}146147template<typename FromType>148void convert_from_sublattice(Matrix<Integer>& ret, const Matrix<FromType> & val) const {149ret=Matrix<Integer>(val.nr_of_rows(),dim);150vector<Integer> v;151for(size_t i=0;i<val.nr_of_rows();++i){152153INTERRUPT_COMPUTATION_BY_EXCEPTION154155convert(v,val[i]);156ret[i]=from_sublattice(v);157}158}159160template<typename ToType, typename FromType>161void convert_to_sublattice_dual(ToType& ret, const FromType& val) const {162convert(ret, to_sublattice_dual(val));163}164165template<typename ToType>166void convert_to_sublattice_dual(Matrix<ToType>& ret, const Matrix<Integer> & val) const {167ret=Matrix<ToType>(val.nr_of_rows(),rank);168vector<Integer> v;169for(size_t i=0;i<val.nr_of_rows();++i){170v=to_sublattice_dual(val[i]);171convert(ret[i],v);172}173}174175template<typename ToType, typename FromType>176void convert_from_sublattice_dual(ToType& ret, const FromType& val) const {177ret = from_sublattice_dual(convertTo<ToType>(val));178}179180template<typename FromType>181void convert_from_sublattice_dual(Matrix<Integer>& ret, const Matrix<FromType> & val) const {182ret=Matrix<Integer>(val.nr_of_rows(),dim);183vector<Integer> v;184for(size_t i=0;i<val.nr_of_rows();++i){185186INTERRUPT_COMPUTATION_BY_EXCEPTION187188convert(v,val[i]);189ret[i]=from_sublattice_dual(v);190}191}192193template<typename ToType, typename FromType>194void convert_to_sublattice_dual_no_div(ToType& ret, const FromType& val) const {195convert(ret, to_sublattice_dual_no_div(val));196}197198template<typename ToType>199void convert_to_sublattice_dual_no_div(Matrix<ToType>& ret, const Matrix<Integer> & val) const {200ret=Matrix<ToType>(val.nr_of_rows(),rank);201vector<Integer> v;202for(size_t i=0;i<val.nr_of_rows();++i){203v=to_sublattice_dual_no_div(val[i]);204convert(ret[i],v);205}206}207208209//---------------------------------------------------------------------------210// Data acces211//---------------------------------------------------------------------------212213/* returns the dimension of the ambient space */214size_t getDim() const;215216/* returns the rank of the sublattice */217size_t getRank() const;218219Integer getAnnihilator() const;220bool IsIdentity()const;221222const Matrix<Integer>& getEquationsMatrix() const;223const vector<vector<Integer> >& getEquations() const;224const Matrix<Integer>& getCongruencesMatrix() const;225const vector<vector<Integer> >& getCongruences() const;226mpz_class getExternalIndex() const;227const Matrix<Integer>& getEmbeddingMatrix() const;228const vector<vector<Integer> >& getEmbedding() const;229const Matrix<Integer>& getProjectionMatrix() const;230const vector<vector<Integer> >& getProjection() const;231232};233234}235236//---------------------------------------------------------------------------237#endif238//---------------------------------------------------------------------------239240241