/usr/include/givaro/StaticElement.h is in libgivaro-dev 3.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | //==================================================================
// Copyright(c)'1994-2009 by The Givaro group
// This file is part of Givaro.
// Givaro is governed by the CeCILL-B license under French law
// and abiding by the rules of distribution of free software.
// see the COPYRIGHT file for more details.
// -----------------------------------------------------------------
// Time-stamp: <10 Oct 12 16:04:17 Jean-Guillaume.Dumas@imag.fr>
// -----------------------------------------------------------------
// author: Jean-Guillaume.Dumas
// date: 2004
//==================================================================
/*! @file StaticElement.h
* @ingroup zpz
* @brief NO DOC
*/
#ifndef __GIVARO_static_element_H
#define __GIVARO_static_element_H
#include <iostream>
#include "gmp++/gmp++.h"
namespace Givaro {
//! Static Element
template <class DomainStyle>
struct StaticElement {
typedef DomainStyle Domain;
protected:
static Domain _domain;
typedef typename Domain::Element Rep;
Rep _elem;
public:
static void setDomain(const Domain& D) {
StaticElement::_domain = D;
}
static Domain getDomain() {
return StaticElement::_domain;
}
StaticElement() { _domain.init(_elem); }
StaticElement(const Integer& i) { _domain.init( (_elem), i); }
StaticElement(const double& i) { _domain.init( (_elem), i); }
StaticElement(const int& i) { _domain.init( (_elem), (long)i); }
StaticElement(const unsigned int& i) { _domain.init( (_elem), (unsigned long)i); }
StaticElement(const long& i) { _domain.init( (_elem), i); }
StaticElement(const unsigned long& i) { _domain.init( (_elem), i); }
operator short() const { long tmp; return (short)_domain.convert(tmp,_elem); }
operator unsigned short() const { unsigned long tmp; return (unsigned short)_domain.convert(tmp,_elem); }
operator unsigned char() const { unsigned long tmp; return (unsigned char)_domain.convert(tmp,_elem); }
operator unsigned int() const { unsigned long tmp; return (unsigned int)_domain.convert(tmp,_elem); }
operator int() const { long tmp; return (int)_domain.convert(tmp,_elem); }
operator float() const { double tmp; return (float)_domain.convert(tmp,_elem); }
operator unsigned long() const { unsigned long tmp; return _domain.convert(tmp,_elem); }
operator long() const { long tmp; return _domain.convert(tmp,_elem); }
operator double() const { double tmp; return (double)_domain.convert(tmp,_elem); }
operator Integer() const { Integer tmp; return _domain.convert(tmp,_elem); }
#ifndef __GIVARO__DONOTUSE_longlong__
operator unsigned long long() const { Integer tmp; return (unsigned long long)_domain.convert(tmp,_elem); }
operator long long() const { Integer tmp; return (long long)_domain.convert(tmp,_elem); }
#endif
template<class INITCST>
operator INITCST() const { INITCST tmp; return _domain.convert(tmp,_elem); }
template<class INITCST>
StaticElement(const INITCST& i) { _domain.init( (_elem), i); }
template<class INITCST>
StaticElement(const INITCST& i, const Domain& D) {
setDomain(D);
_domain.init((_elem), i);
}
StaticElement& operator=( const StaticElement& e) {
_domain.assign((_elem), e._elem); return *this;
}
bool operator==(const StaticElement& e) {
return _domain.areEqual((_elem), e._elem);
}
bool operator!=(const StaticElement& e) {
return !_domain.areEqual((_elem), e._elem);
}
inline const StaticElement operator* (const StaticElement& e) const {
StaticElement tmp;
StaticElement(_domain.mul(tmp._elem,(_elem), e._elem));
return tmp;
}
inline const StaticElement operator/ (const StaticElement& e) const {
StaticElement tmp;
StaticElement(_domain.div(tmp._elem,(_elem), e._elem));
return tmp;
}
inline const StaticElement operator+ (const StaticElement& e) const {
StaticElement tmp;
StaticElement(_domain.add(tmp._elem,(_elem), e._elem));
return tmp;
}
inline const StaticElement operator- (const StaticElement& e) const {
StaticElement tmp;
StaticElement(_domain.sub(tmp._elem,(_elem), e._elem));
return tmp;
}
inline const StaticElement operator- () const {
StaticElement tmp;
StaticElement(_domain.neg(tmp._elem,(_elem)));
return tmp;
}
inline StaticElement& operator*= (const StaticElement& e) {
_domain.mulin((_elem), e._elem); return *this;
}
inline StaticElement& operator/= (const StaticElement& e) {
_domain.divin((_elem), e._elem); return *this;
}
inline StaticElement& operator+= (const StaticElement& e) {
_domain.addin((_elem), e._elem); return *this;
}
inline StaticElement& operator-= (const StaticElement& e) {
_domain.subin((_elem), e._elem); return *this;
}
inline StaticElement& operator-- () {
_domain.subin(this->_elem, _domain.one); return *this;
}
inline StaticElement& operator++ () {
_domain.addin(this->_elem, _domain.one); return *this;
}
inline StaticElement operator-- (int) {
StaticElement tmp(*this);
_domain.subin(this->_elem, _domain.one); return tmp;
}
inline StaticElement operator++ (int) {
StaticElement tmp(*this);
_domain.addin(this->_elem, _domain.one); return tmp;
}
friend inline std::istream& operator>> (std::istream& i, StaticElement& a) {
return _domain.read(i,(a._elem));
}
friend inline std::ostream& operator<< (std::ostream& o, const StaticElement& a) {
return _domain.write(o,(a._elem));
}
};
} // namespace Givaro
#endif // __GIVARO_static_element_H
|