My Project
Loading...
Searching...
No Matches
imm.h File Reference

operations on immediates, that is elements of F_p, GF, Z, Q that fit into intrinsic int, long More...

#include <stdint.h>
#include <iostream>
#include "cf_assert.h"
#include "cf_defs.h"
#include "cf_globals.h"
#include "ffops.h"
#include "gfops.h"
#include "cf_factory.h"
#include "canonicalform.h"
#include "int_cf.h"

Go to the source code of this file.

Macros

#define OSTREAM   std::ostream

Functions

static long imm2int (const InternalCF *const imm)
static InternalCFint2imm (long i)
InternalCFint2imm_p (long i)
InternalCFint2imm_gf (long i)
int imm_isone (const InternalCF *const ptr)
int imm_isone_p (const InternalCF *const ptr)
int imm_isone_gf (const InternalCF *const ptr)
int imm_iszero (const InternalCF *const ptr)
int imm_iszero_p (const InternalCF *const ptr)
int imm_iszero_gf (const InternalCF *const ptr)
long imm_intval (const InternalCF *const op)
int imm_sign (const InternalCF *const op)
 imm_sign() - return sign of immediate object.

Variables

const long INTMARK = 1
const long FFMARK = 2
const long GFMARK = 3
const long MINIMMEDIATE = -(1L<<60)+2L
const long MAXIMMEDIATE = (1L<<60)-2L
const FACTORY_INT64 MINIMMEDIATELL = -268435454LL
const FACTORY_INT64 MAXIMMEDIATELL = 268435454LL

Detailed Description

operations on immediates, that is elements of F_p, GF, Z, Q that fit into intrinsic int, long

Definition in file imm.h.

Macro Definition Documentation

◆ OSTREAM

#define OSTREAM   std::ostream

Definition at line 20 of file imm.h.

Function Documentation

◆ imm2int()

long imm2int ( const InternalCF *const imm)
inlinestatic

Definition at line 70 of file imm.h.

71{
72 return ((intptr_t)imm) >> 2;
73}

◆ imm_intval()

long imm_intval ( const InternalCF *const op)
inline

Definition at line 164 of file imm.h.

165{
166 if ( is_imm( op ) == FFMARK )
167 {
168 if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) )
169 return ff_symmetric( imm2int( op ) );
170 else
171 return imm2int( op );
172 }
173 else if ( is_imm( op ) == GFMARK )
174 {
175 ASSERT( gf_isff( imm2int( op ) ), "invalid conversion" );
176 if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) )
177 return ff_symmetric( gf_gf2ff( imm2int( op ) ) );
178 else
179 return gf_gf2ff( imm2int( op ) );
180 }
181 /*else*/
182 return imm2int( op );
183}
int is_imm(const InternalCF *const ptr)
#define ASSERT(expression, message)
Definition cf_assert.h:99
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
Definition cf_defs.h:33
INST_VAR CFSwitches cf_glob_switches
long gf_gf2ff(long a)
Definition gfops.cc:209
bool gf_isff(long a)
Definition gfops.cc:253
int ff_symmetric(const int a)
Definition ffops.h:67
static long imm2int(const InternalCF *const imm)
Definition imm.h:70
const long FFMARK
Definition imm.h:38
const long GFMARK
Definition imm.h:39

◆ imm_isone()

int imm_isone ( const InternalCF *const ptr)
inline

Definition at line 124 of file imm.h.

125{
126 return imm2int( ptr ) == 1;
127}

◆ imm_isone_gf()

int imm_isone_gf ( const InternalCF *const ptr)
inline

Definition at line 136 of file imm.h.

137{
138 return gf_isone( imm2int( ptr ) );
139}
bool gf_isone(int a)
Definition gfops.h:53

◆ imm_isone_p()

int imm_isone_p ( const InternalCF *const ptr)
inline

Definition at line 130 of file imm.h.

131{
132 return imm2int( ptr ) == 1;
133}

◆ imm_iszero()

int imm_iszero ( const InternalCF *const ptr)
inline

Definition at line 145 of file imm.h.

146{
147 return imm2int( ptr ) == 0;
148}

◆ imm_iszero_gf()

int imm_iszero_gf ( const InternalCF *const ptr)
inline

Definition at line 157 of file imm.h.

158{
159 return gf_iszero( imm2int( ptr ) );
160}
bool gf_iszero(int a)
Definition gfops.h:43

◆ imm_iszero_p()

int imm_iszero_p ( const InternalCF *const ptr)
inline

Definition at line 151 of file imm.h.

152{
153 return imm2int( ptr ) == 0;
154}

◆ imm_sign()

int imm_sign ( const InternalCF *const op)
inline

imm_sign() - return sign of immediate object.

If CO is an immediate integer, the sign is defined as usual. If CO is an element of FF(p) and SW_SYMMETRIC_FF is on the sign of CO is the sign of the symmetric representation of CO. If CO is in GF(q) or in FF(p) and SW_SYMMETRIC_FF is off, the sign of CO is zero iff CO is zero, otherwise the sign is one.

See also
CanonicalForm::sign(), gf_sign()

Definition at line 200 of file imm.h.

201{
202 if ( is_imm( op ) == FFMARK )
203 if ( imm2int( op ) == 0 )
204 return 0;
205 else if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) )
206 if ( ff_symmetric( imm2int( op ) ) > 0 )
207 return 1;
208 else
209 return -1;
210 else
211 return 1;
212 else if ( is_imm( op ) == GFMARK )
213 return gf_sign( imm2int( op ) );
214 else if ( imm2int( op ) == 0 )
215 return 0;
216 else if ( imm2int( op ) > 0 )
217 return 1;
218 else
219 return -1;
220}
int gf_sign(int a)
Definition gfops.h:113

◆ int2imm()

InternalCF * int2imm ( long i)
inlinestatic

Definition at line 75 of file imm.h.

76{
77 return (InternalCF*)((i << 2) | INTMARK );
78}
int i
Definition cfEzgcd.cc:132
virtual class for internal CanonicalForm's
Definition int_cf.h:47
const long INTMARK
Definition imm.h:37

◆ int2imm_gf()

InternalCF * int2imm_gf ( long i)
inline

Definition at line 106 of file imm.h.

107{
108 return (InternalCF*)((i << 2) | GFMARK );
109}

◆ int2imm_p()

InternalCF * int2imm_p ( long i)
inline

Definition at line 101 of file imm.h.

102{
103 return (InternalCF*)((i << 2) | FFMARK );
104}

Variable Documentation

◆ FFMARK

const long FFMARK = 2

Definition at line 38 of file imm.h.

◆ GFMARK

const long GFMARK = 3

Definition at line 39 of file imm.h.

◆ INTMARK

const long INTMARK = 1

Definition at line 37 of file imm.h.

◆ MAXIMMEDIATE

const long MAXIMMEDIATE = (1L<<60)-2L

Definition at line 55 of file imm.h.

◆ MAXIMMEDIATELL

const FACTORY_INT64 MAXIMMEDIATELL = 268435454LL

Definition at line 63 of file imm.h.

◆ MINIMMEDIATE

const long MINIMMEDIATE = -(1L<<60)+2L

Definition at line 54 of file imm.h.

◆ MINIMMEDIATELL

const FACTORY_INT64 MINIMMEDIATELL = -268435454LL

Definition at line 62 of file imm.h.