I'm working on a modelling a algebraic group on C++, over a class of modular integers (simpliying):
template<unsigned int N>
struct modint_t {
private:
unsigned int m_i{};
// now I implement all operators of int except those about bitwise
public:
// the three constructors by default
// explicit constructor from ints
//
// operator < same as between integers but only in their range
// operator > These comparators are not agreed with the operations
// operator <= of the ring of modular integers.
// operator >= But they are helping with the work.
// operator == it fully agrees with the modular integers ring
// operator != it fully agrees with the modular integers ring
// operator = Both assignations by default
//
// binary operators +,+=,-,-=,*,*=,^,^= (the two las are
// exponentiation)
// unary operators (or like operators) -, ~, !, CB,CBm1,mCB,mCBm1
// inv, invert
// ~ and CBm1 are de complement to the Module minus 1
// a.mCBm1() := a = a.CBm1(); a.mCBm1 := a = ~a;
// CB and - are the complement to de Module
// a.mCB() := a = a.CB(); a.mCB() == !a;
// a.inv()*a == modint(int(1)) == a*a.inv();
// a.invert() := a = a.inv();
//
// explicit operator int() return a copy of m_i;
//
// operators++(),operator--(),operators++(int),operator--(int)
// next()const ,prev()const ,mnext(),mprev()
// the increment and decrement are circulars and they are agree with
// comparators operators
};
Then I code a modint_cartprod_t, a type that represent a ring of cartesian product of several modular integer rings (very much simplified):
template<unsigned N_0,unsigned ... N_s>
struct modint_cartprod_t{
using base_t = std::tuple<modint_t<N_0>,modint<N_s>...>;
private:
base_t elem{};
// all idem as in modint_t template, it is a ring. Some more
// constructors from list of integers etc. Helping classes and
// functions. I use fold expresions, except for prev(), next()... that
// I use an static_for class with recursion in the operator()
};
// concat of modint_cartprod_t s
// extern product of integer and one modint_t or modint_cartprod_t
// to modelling an algebraic structure of module.
As I want modelling others groups than the direct product of cyclic groups, I code a class without data member, only static operations to conform other operations, as, for example, dihedral groups (semi direct products) or quaternion group (by cohomology) and much others.
template<group_name gn,unsigned N_0,unsigned ... N_s>
struct {
static modint_cartprod_t
direct_product(
modint_cartprod_t a,modint_cartprod_t a
) {return (a+b);}
static modint_cartprod_t
semi_direct_product(
modint_cartprod_t a,modint_cartprod_t a
) {/* operations with an action */}
modint_cartprod_t operator(modint_cartprod_t,modint_cartprod_t);
// intern operation
// neutre() and others if the neutre element exists
// operator-() and others if the inverse of the intern operation
// exists
}
The problem is in this point, for :
template<unsigned N>
struct binop_t<group_name::Dih,uint,2,N> {
static constexpr
modint_cartprod_t Dih_product(modint_cartprod_t a,modint_cartprod_t b)
{
const UIntType i{a.get_int<0>()};/// Module 2 Error HERE
const UIntType k{a.get_int<1>()};/// Module N Error HERE
const UIntType j{b.get_int<0>()};/// Module 2 Error HERE
const UIntType m{b.get_int<1>()};/// Module N Error Here
if (j%2_u8==0) {
const modint_cartprod_t R{i+j,m+k};
return R;
} else {
const modint_cartprod_t R{i+j,m+(N-k)};
return R;
}
}
};
This indicated function doesn't compile with the following error message from compiler mingw gcc8.2 (nuwen distro):
C:\Windows\system32\cmd.exe /C C:/MinGW/bin/make.exe -j8 SHELL=cmd.exe -e -f Makefile "----------Building project:[ grupos_finitos - Debug ]----------" make.exe[1]: Entering directory 'C:/Users/julia/Dropbox/GitHub/tfg_grupos_finitos/grupos_finitos' C:/MinGW/bin/g++.exe -c "C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/main.cpp" -g -O0 -Wall -std=c++17 -o ./Debug/up_up_TFG_GruposFinitos_src_FiniteGroups_main.cpp.o -I. -I. In file included from C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/main.cpp:11: C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp: In static member function 'static constexpr tfg::binop_t<(tfg::group_name)6, unsigned char, 2, N>::modint_cartprod_t tfg::binop_t<(tfg::group_name)6, unsigned char, 2, N>::Dih_product(tfg::binop_t<(tfg::group_name)6, unsigned char, 2, N>::modint_cartprod_t, tfg::binop_t<(tfg::group_name)6, unsigned char, 2, N>::modint_cartprod_t)': C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp:543:29: error: expected primary-expression before ')' token UIntType i = a.get_int<0>();/// Module 2 ^ C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp:544:34: error: expected primary-expression before ')' token const UIntType k {a.get_int<1>()};/// Module N ^ C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp:546:24: error: expected primary-expression before ')' token auto j {b.get_int<0>()};/// Module 2 ^ C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp:547:30: error: expected primary-expression before ')' token const auto m {b.get_int<1>()};/// Module N ^ C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp: In static member function 'static constexpr tfg::binop_t<(tfg::group_name)10, unsigned char, 2, N>::modint_cartprod_t tfg::binop_t<(tfg::group_name)10, unsigned char, 2, N>::Dic_product(tfg::binop_t<(tfg::group_name)10, unsigned char, 2, N>::modint_cartprod_t, tfg::binop_t<(tfg::group_name)10, unsigned char, 2, N>::modint_cartprod_t)': C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp:608:24: error: no match for 'operator+=' (operand types are 'tfg::modint_cartprod_t::modint_idx<1>' {aka 'tfg::modint_t'} and 'int') sr.get_modint<1>() += (N/2); ~~~~~~~~~~~~~~~~~~~^~~~~~~~ In file included from C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/main.cpp:9: C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/modint_t.hpp:202:19: note: candidate: 'const tfg::modint_t& tfg::modint_t::operator+=(const tfg::modint_t&) [with UIntType = unsigned char; UIntType N = 2]' const modint_t & operator += (const modint_t & b) { ^~~~~~~~ C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/modint_t.hpp:202:19: note: no known conversion for argument 1 from 'int' to 'const tfg::modint_t&' In file included from C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/main.cpp:11: C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp: In static member function 'static constexpr tfg::binop_t<(tfg::group_name)35, UIntType, p, q>::modint_cartprod_t tfg::binop_t<(tfg::group_name)35, UIntType, p, q>::GDih_action(tfg::binop_t<(tfg::group_name)35, UIntType, p, q>::modint_cartprod_t, tfg::binop_t<(tfg::group_name)35, UIntType, p, q>::modint_cartprod_t)': C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp:666:33: error: expected primary-expression before ')' token const UIntType i{a.get_int<0>()}; ^ C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp:667:33: error: expected primary-expression before ')' token const UIntType j{a.get_int<1>()}; ^ C:/Users/julia/Dropbox/GitHub/TFG_GruposFinitos/src/FiniteGroups/binop_t.hpp:669:33: error: expected primary-expression before ')' token const UIntType k{b.get_int<0>()}; ^ make.exe[1]: * [grupos_finitos.mk:97: Debug/up_up_TFG_GruposFinitos_src_FiniteGroups_main.cpp.o] Error 1 make.exe: * [Makefile:5: All] Error 2 make.exe[1]: Leaving directory 'C:/Users/julia/Dropbox/GitHub/tfg_grupos_finitos/grupos_finitos' ====26 errors, 10 warnings====
I don't understand:
error: expected primary-expression before ')' token UIntType i = a.get_int<0>();/// Module 2 ^ The code of get_int<>() is:
template<typename UIntType,UIntType N_0,UIntType ... N_s>
struct modint_cartprod_t {
using std::get;
template<size_t k>
inline constexpr
UIntType
get_int() const {
return UIntType(get<k>(elem));
}
};
In others binop of groups this function compiles without signal of error.
I don't know that I can do to compile the code. I don't know really where is the error.
I you need the code, say me, and I put in GitHub all the code and I give you the link.
Aucun commentaire:
Enregistrer un commentaire