/usr/include/givaro/givops.h is in libgivaro-dev 3.7.2-1.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 | // ==========================================================================
// $Source: /var/lib/cvs/Givaro/src/library/tools/givops.h,v $
// 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.
// Authors: T. Gautier
// $Id: givops.h,v 1.3 2009-09-17 14:28:23 jgdumas Exp $
// ==========================================================================
// Description:
// Class version of operations on a group F. By default use arithmetic operator
#ifndef __GIVARO_operation_H
#define __GIVARO_operation_H
//
#include "givaro/givconfig.h"
#include "givaro/giviterator.h"
namespace Givaro {
template<class Domain>
struct BaseOP {
typedef typename Domain::Rep Type_t;
typedef Domain Domain_t;
const Domain& _domain;
BaseOP( const Domain& D ) : _domain(D) {}
};
template<class Domain>
struct CopyOp : public BaseOP<Domain> {
typedef typename BaseOP<Domain>::Type_t Type_t;
typedef Domain Domain_t;
CopyOp( const Domain& D ) : BaseOP<Domain>(D) {}
void operator() (Type_t& v1, const Type_t& v2) const {
BaseOP<Domain>::_domain.assign(v1, v2);
}
};
// -- Default operators
template<class Domain>
struct MulOp : public BaseOP<Domain> {
typedef typename BaseOP<Domain>::Type_t Type_t;
typedef Domain Domain_t;
MulOp( const Domain& D ) : BaseOP<Domain>(D) {}
void operator() (Type_t& res, const Type_t& v1, const Type_t& v2) const
{ BaseOP<Domain>::_domain.mul( res, v1, v2); }
void operator() (Type_t& res, const Type_t& v1 ) const
{ BaseOP<Domain>::_domain.mulin( res, v1 ); }
};
template<class Domain>
struct DivOp : public BaseOP<Domain> {
typedef typename BaseOP<Domain>::Type_t Type_t;
typedef Domain Domain_t;
DivOp( const Domain& D ) : BaseOP<Domain>(D) {}
void operator() (Type_t& res, const Type_t& v1, const Type_t& v2) const
{ BaseOP<Domain>::_domain.div( res, v1, v2); }
void operator() (Type_t& res, const Type_t& v1) const
{ BaseOP<Domain>::_domain.divin( res, v1 ); }
};
template<class Domain>
struct ModOp : public BaseOP<Domain> {
typedef typename BaseOP<Domain>::Type_t Type_t;
typedef Domain Domain_t;
ModOp( const Domain& D ) : BaseOP<Domain>(D) {}
void operator() (Type_t& res, const Type_t& v1, const Type_t& v2) const
{ BaseOP<Domain>::_domain.mod( res, v1, v2); }
void operator() (Type_t& res, const Type_t& v1) const
{ BaseOP<Domain>::_domain.modin( res, v1 ); }
};
template<class Domain>
struct AddOp : public BaseOP<Domain> {
typedef typename BaseOP<Domain>::Type_t Type_t;
typedef Domain Domain_t;
AddOp( const Domain& D ) : BaseOP<Domain>(D) {}
void operator() (Type_t& res, const Type_t& v1, const Type_t& v2) const
{ BaseOP<Domain>::_domain.add( res, v1, v2 ); }
void operator() (Type_t& res, const Type_t& v1) const
{ BaseOP<Domain>::_domain.addin( res, v1 ); }
};
template<class Domain>
struct SubOp : public BaseOP<Domain> {
typedef typename BaseOP<Domain>::Type_t Type_t;
typedef Domain Domain_t;
SubOp( const Domain& D ) : BaseOP<Domain>(D) {}
void operator() (Type_t& res, const Type_t& v1, const Type_t& v2) const
{ BaseOP<Domain>::_domain.sub( res, v1, v2 ); }
void operator() (Type_t& res, const Type_t& v1) const
{ BaseOP<Domain>::_domain.subin( res, v1 ); }
};
template<class Domain>
struct NegOp : public BaseOP<Domain> {
typedef typename BaseOP<Domain>::Type_t Type_t;
typedef Domain Domain_t;
NegOp( const Domain& D ) : BaseOP<Domain>(D) {}
void operator() (Type_t& res, const Type_t& v1) const
{ BaseOP<Domain>::_domain.neg( res, v1 ); }
void operator() (Type_t& res ) const
{ BaseOP<Domain>::_domain.negin( res, res ); }
};
template<class Domain>
struct MulAddOp : public BaseOP<Domain> {
typedef typename BaseOP<Domain>::Type_t Type_t;
typedef Domain Domain_t;
MulAddOp( const Domain& D ) : BaseOP<Domain>(D) {}
void operator()(Type_t& res, const Type_t& v1, const Type_t& v2, const Type_t& v3) const
{ BaseOP<Domain>::_domain.axpy( res, v1, v2, v3 ); }
void operator() (Type_t& res, const Type_t& v1, const Type_t& v2 ) const
{ BaseOP<Domain>::_domain.axpyin( res, v1, v2 ); }
};
// -- BinOP -> UnOP
// -- UnOp -> Zero OP
template<class OP>
struct Curried1 : public OP {
typedef typename OP::Type_t Type_t;
typedef typename OP::Domain_t Domain_t;
Type_t& _val;
Curried1( const Domain_t& D, Type_t& val ) : OP(D), _val(val) {}
Curried1( const Domain_t& D, const Type_t& val ) : OP(D), _val((Type_t&)val) {}
void operator()(Type_t& v1, const Type_t& v2) { OP::operator()(v1, _val, v2); }
void operator()(Type_t& v1) { OP::operator()(v1, _val); }
};
// -- BinOP -> UnOP
template<class OP>
struct Curried2 : public OP {
typedef typename OP::Type_t Type_t;
typedef typename OP::Domain_t Domain_t;
const Type_t& _val;
Curried2( const Domain_t& D, Type_t& val ) : OP(D), _val(val) {}
Curried2( const Domain_t& D, const Type_t& val ) : OP(D), _val((Type_t&)val) {}
void operator()(Type_t& v1, const Type_t& v2) { OP::operator()(v1, v2, _val); }
void operator()(Type_t& v1) { OP::operator()(v1, _val); }
};
} // Givaro
#endif
|