Loading...
Searching...
No Matches
rings_test.h
Go to the documentation of this file.
#include "common.h"
using namespace std;
// the following headers are private...
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.h"
class MyGlobalPrintingFixture : public GlobalPrintingFixture
{
public:
virtual bool setUpWorld()
{
GlobalPrintingFixture::setUpWorld();
//TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp );
//TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF );
//TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
//TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q );
//TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );
#ifdef HAVE_RINGS
//TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment!
#endif
return true;
}
};
//
// We can rely on this file being included exactly once
// and declare this global variable in the header file.
//
static MyGlobalPrintingFixture globalPrintingFixture;
namespace
{
void PrintRing(const ring r)
{
rWrite(r); PrintLn();
#ifdef RDEBUG
rDebugPrint(r); PrintLn();
#endif
}
static inline void Test(const ring)
{
// does nothing yet...
}
}
class PolysTestSuite : public CxxTest::TestSuite
{
public:
void test_Z13_t()
{
clog << "Creating Z/13[t]: " << endl;
char* n[] = { (char*)"t"};
ring r = rDefault( 13, 1, n);
TS_ASSERT_DIFFERS( r, NULLp );
PrintRing(r);
TS_ASSERT( rField_is_Domain(r) );
TS_ASSERT( !rField_is_Q(r) );
TS_ASSERT( rField_is_Zp(r) );
TS_ASSERT( !rField_is_Zp(r, 11) );
TS_ASSERT( rField_is_Zp(r, 13) );
TS_ASSERT_EQUALS( rVar(r), 1);
Test(r);
rDelete(r);
}
void test_QQ_t()
{
clog << "Creating Q[s]: " << endl;
char* n[] = {(char*)"s"};
ring r = rDefault( 0, 1, n);
TS_ASSERT_DIFFERS( r, NULLp );
PrintRing(r);
TS_ASSERT( rField_is_Domain(r) );
TS_ASSERT( rField_is_Q(r) );
TS_ASSERT( !rField_is_Zp(r) );
TS_ASSERT( !rField_is_Zp(r, 11) );
TS_ASSERT_EQUALS( rVar(r), 1);
Test(r);
rDelete(r);
}
void test_Z11_x_y_z()
{
clog << "Creating Z/11[x, y, z]: " << endl;
char* n[] = {(char*)"x", (char*)"y", (char*)"z"};
ring r = rDefault( 11, 3, n);
TS_ASSERT_DIFFERS( r, NULLp );
PrintRing(r);
TS_ASSERT( rField_is_Domain(r) );
TS_ASSERT( !rField_is_Q(r) );
TS_ASSERT( rField_is_Zp(r) );
TS_ASSERT( rField_is_Zp(r, 11) );
TS_ASSERT( !rField_is_Zp(r, 13) );
TS_ASSERT_EQUALS( rVar(r), 3);
Test(r);
rDelete(r);
}
void test_QQ_x_y_z()
{
clog << "Creating QQ[x, y, z, u]: " << endl;
char* n[] = {(char*)"x", (char*)"y", (char*)"z", (char*)"u"};
ring r = rDefault( 0, 4, n);
TS_ASSERT_DIFFERS( r, NULLp );
PrintRing(r);
TS_ASSERT( rField_is_Domain(r) );
TS_ASSERT( rField_is_Q(r) );
TS_ASSERT( !rField_is_Zp(r) );
TS_ASSERT( !rField_is_Zp(r, 11) );
TS_ASSERT_EQUALS( rVar(r), 4);
Test(r);
rDelete(r);
}
void test_Z13_t_GF()
{
clog << "Creating GF[t]: " << endl;
char* n[] = {(char*)"t"};
GFInfo param;
param.GFChar= 5;
param.GFDegree= 2;
param.GFPar_name= (const char*)"Q";
const coeffs cf = nInitChar( n_GF, &param );
TS_ASSERT_DIFFERS( cf, NULLp );
ring r = rDefault( cf, 1, n); // now cf belongs to r!
TS_ASSERT_DIFFERS( r, NULLp );
PrintRing(r);
TS_ASSERT( rField_is_Domain(r) );
TS_ASSERT( !rField_is_Q(r) );
TS_ASSERT( !rField_is_Zp(r) );
TS_ASSERT( !rField_is_Zp(r, 11) );
TS_ASSERT( !rField_is_Zp(r, 13) );
TS_ASSERT( rField_is_GF(r) );
TS_ASSERT( rField_is_GF(r, 5) );
TS_ASSERT( !rField_is_GF(r, 25) );
TS_ASSERT_EQUALS( rVar(r), 1);
Test(r);
rDelete(r); // kills 'cf' as well!
}
void test_QQ_x_y_z_ord_2_lp()
{
clog << "Creating QQ[x, y, z, u]: " << endl;
const int N = 4;
char* n[N] = {(char*)"x", (char*)"y", (char*)"z", (char*)"u"};
const int D = 2;
/*order: lp,0*/
rRingOrder_t *order = (rRingOrder_t *) omAlloc0(D* sizeof(rRingOrder_t));
int *block0 = (int *)omAlloc0(D * sizeof(int));
int *block1 = (int *)omAlloc0(D * sizeof(int));
/* ringorder dp for the first block: var 1..N */
order[0] = ringorder_dp;
block0[0] = 1;
block1[0] = N;
/* the last block: everything is 0 */
// order[1] = 0;
ring r = rDefault(0, N, n, D, order, block0, block1);
TS_ASSERT_DIFFERS( r, NULLp );
PrintRing(r);
TS_ASSERT( rField_is_Domain(r) );
TS_ASSERT( rField_is_Q(r) );
TS_ASSERT( !rField_is_Zp(r) );
TS_ASSERT( !rField_is_Zp(r, 11) );
TS_ASSERT_EQUALS( rVar(r), N);
Test(r);
rDelete(r);
}
};
TS_ASSERT_EQUALS
#define TS_ASSERT_EQUALS(x, y)
Definition TestSuite.h:255
TS_ASSERT_DIFFERS
#define TS_ASSERT_DIFFERS(x, y)
Definition TestSuite.h:287
TS_ASSERT
#define TS_ASSERT(e)
Definition TestSuite.h:239
NULLp
#define NULLp
Definition auxiliary.h:109
N
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
CxxTest::TestSuite
Definition TestSuite.h:22
GlobalPrintingFixture
Definition common.h:91
GlobalPrintingFixture::setUpWorld
virtual bool setUpWorld()
Definition common.h:116
MyGlobalPrintingFixture
Definition polys_test.h:25
MyGlobalPrintingFixture::setUpWorld
virtual bool setUpWorld()
Definition rings_test.h:16
PolysTestSuite
Definition polys_test.h:210
PolysTestSuite::test_QQ_x_y_z_ord_2_lp
void test_QQ_x_y_z_ord_2_lp()
Definition rings_test.h:201
PolysTestSuite::test_QQ_t
void test_QQ_t()
Definition rings_test.h:87
PolysTestSuite::test_Z11_x_y_z
void test_Z11_x_y_z()
Definition rings_test.h:110
PolysTestSuite::test_Z13_t_GF
void test_Z13_t_GF()
Definition rings_test.h:158
PolysTestSuite::test_QQ_x_y_z
void test_QQ_x_y_z()
Definition rings_test.h:134
PolysTestSuite::test_Z13_t
void test_Z13_t()
Definition rings_test.h:63
GFInfo::GFDegree
int GFDegree
Definition coeffs.h:102
n_GF
@ n_GF
\GF{p^n < 2^16}
Definition coeffs.h:32
nInitChar
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:412
GFInfo::GFPar_name
const char * GFPar_name
Definition coeffs.h:103
GFInfo::GFChar
int GFChar
Definition coeffs.h:101
GFInfo
Creation data needed for finite fields.
Definition coeffs.h:100
globalPrintingFixture
static GlobalPrintingFixture globalPrintingFixture
Definition coeffs_test.h:350
Test
BOOLEAN Test(const n_coeffType type, void *p=NULLp)
Definition coeffs_test.h:209
common.h
D
#define D(A)
Definition gentable.cc:128
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
p_polys.h
PrintLn
void PrintLn()
Definition reporter.cc:314
rWrite
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
rDebugPrint
void rDebugPrint(const ring r)
Definition ring.cc:4214
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
rDefault
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition ring.cc:103
ring.h
rField_is_Zp
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506
rField_is_Domain
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:493
rRingOrder_t
rRingOrder_t
order stuff
Definition ring.h:69
ringorder_dp
@ ringorder_dp
Definition ring.h:79
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
rField_is_GF
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:527
rVar
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:598