/usr/include/linbox/ring/archetype.h is in liblinbox-dev 1.3.2-1.1build2.
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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | /* linbox/ring/archetype.h
* Copyright(C) LinBox
* Written by J-G Dumas <Jean-Guillaume.Dumas@imag.fr>,
* Clement Pernet <Clement.Pernet@imag.fr>
*
* ========LICENCE========
* This file is part of the library LinBox.
*
* LinBox 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 ring/archetype.h
* @ingroup ring
* @brief Specification and archetypic instance for the ring interface.
* @see \ref Archetypes
*/
#ifndef __LINBOX_ring_archetype_H
#define __LINBOX_ring_archetype_H
#include <iostream>
#include "linbox/field/archetype.h"
#include "linbox/ring/ring-interface.h"
#include "linbox/ring/abstract.h"
#include "linbox/ring/envelope.h"
#include "linbox/element/archetype.h"
#include "linbox/element/abstract.h"
#include "linbox/element/envelope.h"
#include "linbox/randiter/abstract.h"
#include "linbox/randiter/envelope.h"
#include "linbox/randiter/archetype.h"
#include "linbox/integer.h"
#include "linbox/linbox-config.h"
#include "linbox/util/error.h"
namespace LinBox
{
// Forward declarations
class RandIterArchetype;
/**
* \brief specification and archetypic instance for the ring interface
\ingroup ring
*
* The \ref RingArchetype and its encapsulated
* element class contain pointers to the \ref RingAbstract
* and its encapsulated ring element, respectively.
* \ref RingAbstract then uses virtual member functions to
* define operations on its encapsulated ring element. This ring
* element has no knowledge of the ring properties being used on it
* which means the ring object must supply these operations.
*
* It does not contain elements zero and one because they can be created
* whenever necessary, although it might be beneficial from an efficiency
* stand point to include them. However, because of archetype use three,
* the elements themselves cannot be contained, but rather pointers to them.
*/
class RingArchetype : public virtual FieldArchetype {
public:
/** @name Common Object Interface for a LinBox Ring.
* These methods are required of all \ref LinBox rings.
*/
//@{
/// element type.
/* typedef ElementArchetype Element; */
typedef FieldArchetype::Element Element;
/// Random iterator generator type.
/* typedef RandIterArchetype RandIter; */
typedef FieldArchetype::RandIter RandIter;
/// @name Object Management
//@{
/** Copy constructor.
*
* Constructs RingArchetype object by copying the
* ring. This is required to allow ring objects to
* be passed by value into functions.
*
* In this implementation, this means copying the
* ring to which \c F._ring_ptr points, the
* element to which \c F._elem_ptr points, and the
* random element generator to which
* \c F._randIter_ptr points.
*
* @param F \ref RingArchetype object.
*/
RingArchetype (const RingArchetype &F) :
FieldArchetype ( F )
{ }
/** \brief Invertibility test.
* Test if ring element is invertible.
* This function assumes the ring element has already been
* constructed and initialized.
* In this implementation, this means the \c
* _elem_ptr of x exists and does not point to
* null.
*
* @return boolean true if equals zero, false if not.
* @param x ring element.
*/
bool isUnit (const Element &x) const
{ return _ring_ptr->isUnit (*x._elem_ptr); }
/** Divisibility of zero test.
* Test if ring element is a zero divisor.
* This function assumes the ring element has already been
* constructed and initialized.
*
* In this implementation, this means the \c
* _elem_ptr of x exists and does not point to
* null.
*
* @return boolean true if divides zero, false if not.
* @param x ring element.
*/
bool isZeroDivisor (const Element &x) const
{ return _ring_ptr->isZeroDivisor (*x._elem_ptr); }
/** Constructor.
* Constructs ring from pointer to \ref RingAbstract and its
* encapsulated element and random element generator.
* Not part of the interface.
* Creates new copies of ring, element, and random iterator generator
* objects in dynamic memory.
* @param ring_ptr pointer to \ref RingAbstract.
* @param elem_ptr pointer to \ref ElementAbstract, which is the
* encapsulated element of \ref RingAbstract.
* @param randIter_ptr pointer to \ref RandIterAbstract, which is the
* encapsulated random iterator generator
* of \ref RingAbstract.
*/
RingArchetype (RingAbstract *ring_ptr,
ElementAbstract *elem_ptr,
RandIterAbstract *randIter_ptr = 0) :
FieldArchetype( static_cast<FieldAbstract*>(ring_ptr->clone()),
elem_ptr, randIter_ptr ),
_ring_ptr (dynamic_cast<RingAbstract*>(ring_ptr->clone ()))
{ }
/** Constructor.
* Constructs ring from ANYTHING matching the interface
* using the enveloppe as a \ref RingAbstract and its
* encapsulated element and random element generator if needed.
* @param f
*/
template<class Ring_qcq>
RingArchetype (Ring_qcq *f)
{ Ring_constructor (f, f); }
//@} Implementation-Specific Methods
private:
friend class ElementArchetype;
friend class RandIterArchetype;
/** Pointer to RingAbstract object.
* Not part of the interface.
* Included to allow for archetype use three.
*/
mutable RingAbstract *_ring_ptr;
/** Template method for constructing archetype from a derived class of
* RingAbstract.
* This class is needed to help the constructor differentiate between
* classes derived from RingAbstract and classes that aren't.
* Should be called with the same argument to both parameters?
* @param trait pointer to RingAbstract or class derived from it
* @param ring_ptr pointer to class derived from RingAbstract
*/
template<class Ring_qcq>
void Ring_constructor (RingAbstract *trait,
Ring_qcq *ring_ptr)
{
constructor( static_cast<FieldAbstract*>(trait), ring_ptr);
_ring_ptr = dynamic_cast<RingAbstract*>(ring_ptr->clone ());
}
/** Template method for constructing archetype from a class not derived
* from RingAbstract.
* This class is needed to help the constructor differentiate between
* classes derived from RingAbstract and classes that aren't.
* Should be called with the same argument to both parameters?
* @param trait pointer to class not derived from RingAbstract
* @param ring_ptr pointer to class not derived from RingAbstract
*/
template<class Ring_qcq>
void Ring_constructor (void *trait,
Ring_qcq *ring_ptr)
{
RingEnvelope< Ring_qcq > EnvF (*ring_ptr);
Ring_constructor (static_cast<RingAbstract*> (&EnvF), &EnvF) ;
}
}; // class RingArchetype
} // namespace LinBox
#endif // __LINBOX_ring_archetype_H
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,:0,t0,+0,=s
// Local Variables:
// mode: C++
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 8
// End:
|