/usr/include/fflas-ffpack/field/rns-double-elt.h is in fflas-ffpack-common 2.2.2-5.
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 | /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
/*
* Copyright (C) 2014 the FFLAS-FFPACK group
*
* Written by Pascal Giorgi <pascal.giorgi@lirmm.fr>
*
*
* ========LICENCE========
* This file is part of the library FFLAS-FFPACK.
*
* FFLAS-FFPACK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ========LICENCE========
*.
*/
/*! @file field/rns-double-elt.h
* @ingroup field
* @brief rns elt structure with double support
*/
#ifndef __FFLASFFPACK_field_rns_double_elt_INL
#define __FFLASFFPACK_field_rns_double_elt_INL
#include "fflas-ffpack/utils/fflas_memory.h"
#include "fflas-ffpack/utils/cast.h"
namespace FFPACK {
// forward declaration
struct rns_double_elt_ptr;
struct rns_double_elt_cstptr;
// element of the rns structure (allow virtualization of element from an array of double)
struct rns_double_elt {
double *_ptr;
size_t _stride;
bool _alloc; // specify wether Element owns its memory; alloc is true only through F.init() and _ptr==NULL (this is to handle Element allocated within a matrix)
rns_double_elt(): _ptr(NULL), _stride(0), _alloc(false) {}
~rns_double_elt(){ if (_alloc) FFLAS::fflas_delete(_ptr);}
rns_double_elt(double* p, size_t r, size_t a=false) : _ptr(p), _stride(r), _alloc(a) {}
inline rns_double_elt_ptr operator&() ;
inline rns_double_elt_cstptr operator&()const ;
rns_double_elt(const rns_double_elt& x) : _ptr(x._ptr),_stride(x._stride),_alloc(false) {}
};
// pointer to element of the rns structure (allow virtualization of element from an array of double)
struct rns_double_elt_ptr : public rns_double_elt {
rns_double_elt other;
rns_double_elt_ptr(){}
rns_double_elt_ptr(double* p, size_t r) : rns_double_elt(p,r,false){}
rns_double_elt_ptr(const rns_double_elt_ptr &x) : rns_double_elt(x._ptr,x._stride,false){}
rns_double_elt_ptr(const rns_double_elt_cstptr &x);
rns_double_elt_ptr(rns_double_elt_ptr &&)=default;
//inline operator rns_double_elt_cstptr();
inline rns_double_elt_ptr* operator&(){return this;}
inline rns_double_elt& operator*() {return static_cast<rns_double_elt&>(*this);}
inline rns_double_elt operator[](size_t i) const {return rns_double_elt(_ptr+i,_stride);} // BUGGY
inline rns_double_elt& operator[](size_t i) {other=rns_double_elt(_ptr+i,_stride);return other;} // BUGGY
inline rns_double_elt_ptr operator++() {return rns_double_elt_ptr(_ptr++,_stride);}
inline rns_double_elt_ptr operator--() {return rns_double_elt_ptr(_ptr--,_stride);}
inline rns_double_elt_ptr operator+(size_t inc) {return rns_double_elt_ptr(_ptr+inc,_stride);}
inline rns_double_elt_ptr operator-(size_t inc) {return rns_double_elt_ptr(_ptr-inc,_stride);}
inline rns_double_elt_ptr& operator+=(size_t inc) {_ptr+=inc;return *this;}
inline rns_double_elt_ptr& operator-=(size_t inc) {_ptr-=inc;return *this;}
inline rns_double_elt_ptr& operator=(const rns_double_elt_ptr& x);
bool operator< (const rns_double_elt_ptr& x) {return _ptr < x._ptr;}
bool operator!= (const rns_double_elt_ptr& x) {return _ptr != x._ptr;}
};
struct rns_double_elt_cstptr : public rns_double_elt {
rns_double_elt other;
rns_double_elt_cstptr(){}
rns_double_elt_cstptr(double* p, size_t r) : rns_double_elt(p,r,false){}
rns_double_elt_cstptr(const rns_double_elt_ptr& x) : rns_double_elt(x._ptr,x._stride,false){}
rns_double_elt_cstptr(const rns_double_elt_cstptr& x) : rns_double_elt(x._ptr,x._stride,false){}
rns_double_elt_cstptr(rns_double_elt_cstptr &&)=default;
inline rns_double_elt_cstptr* operator&(){return this;}
inline rns_double_elt& operator*() const {
return *const_cast<rns_double_elt*>(static_cast<const rns_double_elt*>(this));
}
inline rns_double_elt operator[](size_t i)const {return rns_double_elt(_ptr+i,_stride);}
inline rns_double_elt& operator[](size_t i) {other=rns_double_elt(_ptr+i,_stride);return other;} // BUGGY
//inline rns_double_elt& operator[](size_t i)const {return *((*this)+i);}// BUGGY
inline rns_double_elt_cstptr operator++() {return rns_double_elt_cstptr(_ptr++,_stride);}
inline rns_double_elt_cstptr operator--() {return rns_double_elt_cstptr(_ptr--,_stride);}
inline rns_double_elt_cstptr operator+(size_t inc)const {return rns_double_elt_cstptr(_ptr+inc,_stride);}
inline rns_double_elt_cstptr operator-(size_t inc)const {return rns_double_elt_cstptr(_ptr-inc,_stride);}
inline rns_double_elt_cstptr& operator+=(size_t inc) {_ptr+=inc;return *this;}
inline rns_double_elt_cstptr& operator-=(size_t inc) {_ptr-=inc;return *this;}
inline rns_double_elt_cstptr& operator=(const rns_double_elt_cstptr& x);
bool operator< (const rns_double_elt_cstptr& x) {return _ptr < x._ptr;}
bool operator!= (const rns_double_elt_cstptr& x) {return _ptr != x._ptr;}
};
inline rns_double_elt_ptr& rns_double_elt_ptr::operator=(const rns_double_elt_ptr& x) {
if (this != &x){
if (_alloc) FFLAS::fflas_delete(_ptr);
_ptr= x._ptr;
_stride=x._stride;
_alloc=false;
}
return *this;
}
inline rns_double_elt_cstptr& rns_double_elt_cstptr::operator=(const rns_double_elt_cstptr& x) {
if (this != &x){
if (_alloc) FFLAS::fflas_delete(_ptr);
_ptr= x._ptr;
_stride=x._stride;
_alloc=false;
}
return *this;
}
inline rns_double_elt_ptr::rns_double_elt_ptr(const rns_double_elt_cstptr &x)
: rns_double_elt(x._ptr,x._stride,false){}
//inline rns_double_elt_ptr::operator rns_double_elt_cstptr(){return rns_double_elt_cstptr(_ptr,_stride);}
inline rns_double_elt_ptr rns_double_elt::operator&() {return rns_double_elt_ptr(_ptr,_stride);}
inline rns_double_elt_cstptr rns_double_elt::operator&() const {return rns_double_elt_cstptr(_ptr,_stride);}
template<>
inline rns_double_elt_ptr fflas_const_cast (rns_double_elt_cstptr x){return x;}
template<>
inline rns_double_elt_cstptr fflas_const_cast (rns_double_elt_ptr x){return x;}
} // end namespace FFPACK:
#endif // __FFLASFFPACK_field_rns_double_elt_INL
|