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 InternalCF * | int2imm (long i)
InternalCF * | int2imm_p (long i)
InternalCF * | int2imm_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 | ) |

inline static

Definition at line 70 of file imm.h.

{
return ((intptr_t)imm) >> 2;
}

## imm_intval()

long imm_intval | ( | const InternalCF *const | op | ) |

inline

Definition at line 164 of file imm.h.

{
if ( is_imm( op ) == FFMARK )
{
if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) )
return ff_symmetric( imm2int( op ) );
else
return imm2int( op );
}
else if ( is_imm( op ) == GFMARK )
{
ASSERT( gf_isff( imm2int( op ) ), "invalid conversion" );
if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) )
return ff_symmetric( gf_gf2ff( imm2int( op ) ) );
else
return gf_gf2ff( imm2int( op ) );
}
/*else*/
return imm2int( op );
}
is_imm
int is_imm(const InternalCF *const ptr)
Definition canonicalform.h:65
ASSERT
#define ASSERT(expression, message)
Definition cf_assert.h:99
SW_SYMMETRIC_FF
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
Definition cf_defs.h:33
cf_glob_switches
INST_VAR CFSwitches cf_glob_switches
Definition cf_switches.cc:54
gf_gf2ff
long gf_gf2ff(long a)
Definition gfops.cc:209
gf_isff
bool gf_isff(long a)
Definition gfops.cc:253
ff_symmetric
int ff_symmetric(const int a)
Definition ffops.h:67
imm2int
static long imm2int(const InternalCF *const imm)
Definition imm.h:70
FFMARK
const long FFMARK
Definition imm.h:38
GFMARK
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.

{
return imm2int( ptr ) == 1;
}

## imm_isone_gf()

int imm_isone_gf | ( | const InternalCF *const | ptr | ) |

inline

Definition at line 136 of file imm.h.

{
return gf_isone( imm2int( ptr ) );
}
gf_isone
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.

{
return imm2int( ptr ) == 1;
}

## imm_iszero()

int imm_iszero | ( | const InternalCF *const | ptr | ) |

inline

Definition at line 145 of file imm.h.

{
return imm2int( ptr ) == 0;
}

## imm_iszero_gf()

int imm_iszero_gf | ( | const InternalCF *const | ptr | ) |

inline

Definition at line 157 of file imm.h.

{
return gf_iszero( imm2int( ptr ) );
}
gf_iszero
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.

{
return imm2int( ptr ) == 0;
}

## 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.

{
if ( is_imm( op ) == FFMARK )
if ( imm2int( op ) == 0 )
return 0;
else if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) )
if ( ff_symmetric( imm2int( op ) ) > 0 )
return 1;
else
return -1;
else
return 1;
else if ( is_imm( op ) == GFMARK )
return gf_sign( imm2int( op ) );
else if ( imm2int( op ) == 0 )
return 0;
else if ( imm2int( op ) > 0 )
return 1;
else
return -1;
}
gf_sign
int gf_sign(int a)
Definition gfops.h:113

## int2imm()

InternalCF * int2imm | ( | long | i | ) |

inline static

Definition at line 75 of file imm.h.

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

## int2imm_gf()

InternalCF * int2imm_gf | ( | long | i | ) |

inline

Definition at line 106 of file imm.h.

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

## int2imm_p()

InternalCF * int2imm_p | ( | long | i | ) |

inline

Definition at line 101 of file imm.h.

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

## 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.