[785] | 1 | // Utility classes for template numerical arrays
|
---|
| 2 | // R. Ansari, C.Magneville 03/2000
|
---|
| 3 |
|
---|
[2615] | 4 | #include "sopnamsp.h"
|
---|
[785] | 5 | #include "machdefs.h"
|
---|
| 6 | #include "utilarr.h"
|
---|
[3613] | 7 | #include "randr48.h"
|
---|
[785] | 8 |
|
---|
| 9 | // Classe utilitaires
|
---|
[850] | 10 |
|
---|
[1103] | 11 | Sequence::~Sequence()
|
---|
| 12 | {
|
---|
| 13 | }
|
---|
| 14 |
|
---|
[894] | 15 | //////////////////////////////////////////////////////////
|
---|
[926] | 16 | /*!
|
---|
| 17 | \class SOPHYA::RandomSequence
|
---|
| 18 | \ingroup TArray
|
---|
[1404] | 19 | Base class to generate a sequence of random values
|
---|
[926] | 20 | */
|
---|
| 21 |
|
---|
[894] | 22 | /*!
|
---|
[3613] | 23 | \brief constructor using a global default random generator ( RandomGeneratorInterface::GetGlobalRandGenP() )
|
---|
| 24 | \param typ : generated random numbers distribution type: C_RND_Flat,C_RND_Gaussian,C_RND_Poisson,C_RND_Exponential
|
---|
| 25 | \param mean : mean value of the distribution
|
---|
| 26 | \param sigma : standard deviation of the distribution
|
---|
[894] | 27 | */
|
---|
[3613] | 28 | RandomSequence::RandomSequence(int typ, double mean, double sigma)
|
---|
[850] | 29 | {
|
---|
[3613] | 30 | typ_ = (typ == Flat) ? C_RND_Flat: C_RND_Gaussian ;
|
---|
| 31 | mean_ = mean;
|
---|
| 32 | sig_ = sigma;
|
---|
| 33 | rgp_ = RandomGeneratorInterface::GetGlobalRandGenP();
|
---|
[850] | 34 | }
|
---|
[3613] | 35 |
|
---|
| 36 |
|
---|
| 37 | /*!
|
---|
| 38 | \brief constructor with the specification of a RandomGenerator object to be used.
|
---|
| 39 | \param rgen : RandomGeneratorInterface object that should stay valid as long as the RandomSequence object exist.
|
---|
| 40 | \param typ : generated random numbers distribution type: C_RND_Flat,C_RND_Gaussian,C_RND_Poisson,C_RND_Exponential
|
---|
| 41 | \param mean : mean value of the distribution
|
---|
| 42 | \param sigma : standard deviation of the distribution
|
---|
| 43 | */
|
---|
| 44 | RandomSequence::RandomSequence(RandomGeneratorInterface& rgen, RNDTypes rtyp, double mean, double sigma)
|
---|
| 45 | {
|
---|
| 46 | typ_ = rtyp;
|
---|
| 47 | mean_ = mean;
|
---|
| 48 | sig_ = sigma;
|
---|
| 49 | rgp_ = &rgen;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[1103] | 52 | RandomSequence::~RandomSequence()
|
---|
| 53 | {
|
---|
| 54 | }
|
---|
[850] | 55 |
|
---|
[3613] | 56 | double RandomSequence::Next() const
|
---|
[850] | 57 | {
|
---|
[3613] | 58 | switch (typ_) {
|
---|
| 59 | case C_RND_Flat :
|
---|
| 60 | return rgp_->Flatpm1()*sig_ + mean_;
|
---|
| 61 | break;
|
---|
| 62 | case C_RND_Gaussian :
|
---|
| 63 | return rgp_->Gaussian(sig_, mean_);
|
---|
| 64 | break;
|
---|
| 65 | case C_RND_Poisson :
|
---|
| 66 | return rgp_->Poisson(mean_);
|
---|
| 67 | break;
|
---|
| 68 | case C_RND_Exponential :
|
---|
| 69 | return rgp_->Exponential();
|
---|
| 70 | break;
|
---|
| 71 | default :
|
---|
| 72 | return rgp_->Flat01();
|
---|
| 73 | break;
|
---|
| 74 |
|
---|
| 75 | }
|
---|
[850] | 76 | }
|
---|
| 77 |
|
---|
[3613] | 78 | //! \brief Return the next random number
|
---|
[1156] | 79 | MuTyV & RandomSequence::Value(sa_size_t k) const
|
---|
[1103] | 80 | {
|
---|
[3613] | 81 | retv_ = Next();
|
---|
[1103] | 82 | return retv_;
|
---|
| 83 | }
|
---|
[850] | 84 |
|
---|
[1103] | 85 |
|
---|
[894] | 86 | //////////////////////////////////////////////////////////
|
---|
[926] | 87 | /*!
|
---|
[1103] | 88 | \class SOPHYA::RegularSequence
|
---|
[926] | 89 | \ingroup TArray
|
---|
| 90 | Class to generate a sequence of values
|
---|
| 91 | */
|
---|
| 92 |
|
---|
[894] | 93 | //! Constructor
|
---|
| 94 | /*!
|
---|
| 95 | \param start : start value
|
---|
| 96 | \param step : step value
|
---|
[1404] | 97 | \param f : pointer to the sequence function (default = NULL, f(x)=x )
|
---|
[894] | 98 |
|
---|
[1103] | 99 | See \ref RegularSequenceOperat "operator()"
|
---|
[894] | 100 | */
|
---|
[1103] | 101 | RegularSequence::RegularSequence(double start, double step, Arr_DoubleFunctionOfX f)
|
---|
[785] | 102 | {
|
---|
| 103 | start_ = start;
|
---|
| 104 | step_ = step;
|
---|
| 105 | myf_ = f;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
[1103] | 108 | RegularSequence::~RegularSequence()
|
---|
[850] | 109 | {
|
---|
| 110 | }
|
---|
| 111 |
|
---|
[894] | 112 | //! Get the \b k th value
|
---|
| 113 | /*!
|
---|
| 114 | \param k : index of the value
|
---|
[1103] | 115 | \anchor RegularSequenceOperat
|
---|
[1404] | 116 |
|
---|
| 117 | \return f(start+k*step)
|
---|
[894] | 118 |
|
---|
| 119 | */
|
---|
[1103] | 120 |
|
---|
[1156] | 121 | MuTyV & RegularSequence::Value (sa_size_t k) const
|
---|
[785] | 122 | {
|
---|
[1103] | 123 | double x = start_+(double)k*step_;
|
---|
| 124 | if (myf_) x = myf_(x);
|
---|
| 125 | retv_ = x;
|
---|
| 126 | return(retv_);
|
---|
[785] | 127 | }
|
---|
| 128 |
|
---|
[1404] | 129 | /*!
|
---|
| 130 | \class SOPHYA::EnumeratedSequence
|
---|
| 131 | \ingroup TArray
|
---|
| 132 | Explicitly defined sequence of values. The comma operator has
|
---|
| 133 | been redefined to let an easy definition of sequences.
|
---|
| 134 |
|
---|
| 135 | \code
|
---|
| 136 | // Initializing a sequence
|
---|
| 137 | EnumeratedSequence es;
|
---|
| 138 | es = 11, 22, 33, 44, 55, 66;
|
---|
| 139 |
|
---|
| 140 | for(int k=0; k<8; k++)
|
---|
| 141 | cout << " k= " << k << " es(k)= " << es(k) << endl;
|
---|
[1558] | 142 |
|
---|
| 143 | // Decoding a sequence from a string
|
---|
| 144 | EnumeratedSequence ess;
|
---|
| 145 | int nbad;
|
---|
| 146 | ess.Append("56.5 (1.,-1.) 4 8 16", nbad);
|
---|
| 147 | cout << ess;
|
---|
[1404] | 148 | \endcode
|
---|
| 149 | */
|
---|
| 150 |
|
---|
[1558] | 151 | //! Default constructor
|
---|
[1404] | 152 | EnumeratedSequence::EnumeratedSequence()
|
---|
| 153 | {
|
---|
| 154 | }
|
---|
| 155 |
|
---|
[1558] | 156 | //! Copy constructor
|
---|
| 157 | EnumeratedSequence::EnumeratedSequence(EnumeratedSequence const & es)
|
---|
| 158 | {
|
---|
| 159 | Append(es);
|
---|
| 160 | }
|
---|
| 161 |
|
---|
[1103] | 162 | EnumeratedSequence::~EnumeratedSequence()
|
---|
| 163 | {
|
---|
| 164 | }
|
---|
| 165 |
|
---|
[1404] | 166 | //! Return the k th value in the sequence (default = 0)
|
---|
[1156] | 167 | MuTyV & EnumeratedSequence::Value (sa_size_t k) const
|
---|
[1103] | 168 | {
|
---|
[3572] | 169 | if (k >= (sa_size_t)vecv_.size()) retv_ = 0;
|
---|
[1103] | 170 | else retv_ = vecv_[k];
|
---|
| 171 | return(retv_);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
[1558] | 174 | //! Appends a new value to the sequence
|
---|
[1103] | 175 | EnumeratedSequence & EnumeratedSequence::operator , (MuTyV const & v)
|
---|
| 176 | {
|
---|
| 177 | vecv_.push_back(v);
|
---|
| 178 | return(*this);
|
---|
| 179 | }
|
---|
| 180 |
|
---|
[1558] | 181 | //! Initialize the sequence with a single value \b v
|
---|
[1156] | 182 | EnumeratedSequence & EnumeratedSequence::operator = (MuTyV const & v)
|
---|
| 183 | {
|
---|
| 184 | vecv_.clear();
|
---|
| 185 | vecv_.push_back(v);
|
---|
| 186 | return(*this);
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[1558] | 189 | //! Copy operator
|
---|
| 190 | EnumeratedSequence & EnumeratedSequence::operator = (EnumeratedSequence const & seq)
|
---|
[1550] | 191 | {
|
---|
[1558] | 192 | Clear();
|
---|
| 193 | Append(seq);
|
---|
| 194 | return(*this);
|
---|
[1550] | 195 | }
|
---|
| 196 |
|
---|
[1558] | 197 |
|
---|
| 198 | //! Prints the list to the output stream \b os
|
---|
[1550] | 199 | void EnumeratedSequence::Print(ostream& os) const
|
---|
| 200 | {
|
---|
| 201 | os << " EnumeratedSequence::Print() - Size()= " << Size() << endl;
|
---|
[3572] | 202 | for(size_t k=0; k<vecv_.size(); k++) {
|
---|
[1550] | 203 | os << vecv_[k];
|
---|
| 204 | if ((k > 0) && (k%10 == 0)) os << endl;
|
---|
| 205 | else os << " " ;
|
---|
| 206 | }
|
---|
[1558] | 207 | os << endl;
|
---|
[1550] | 208 | return;
|
---|
| 209 | }
|
---|
| 210 |
|
---|
[1558] | 211 | //! Append the \b seq to the end of the sequence.
|
---|
| 212 | /*!
|
---|
| 213 | \return the number of added elements.
|
---|
| 214 | */
|
---|
| 215 | sa_size_t EnumeratedSequence::Append(EnumeratedSequence const & seq)
|
---|
[1550] | 216 | {
|
---|
[3572] | 217 | for(size_t k=0; k<seq.vecv_.size(); k++)
|
---|
[1558] | 218 | vecv_.push_back(seq.vecv_[k]);
|
---|
| 219 | return(seq.vecv_.size());
|
---|
[1550] | 220 | }
|
---|
| 221 |
|
---|
[1558] | 222 | //! Decodes the string, appending values to the end of the sequence.
|
---|
| 223 | /*!
|
---|
| 224 | \param str : string to be decoded
|
---|
[2286] | 225 | \param nbad : number of unmatched quotes or parenthesis (returned value)
|
---|
| 226 | \param sep : word separator in string. Each word is decoded as a MuTyV value.
|
---|
[1558] | 227 | \return the number of added elements.
|
---|
| 228 | */
|
---|
[2286] | 229 | sa_size_t EnumeratedSequence::Append(string const & str, int& nbad, const char* sep)
|
---|
[1558] | 230 | {
|
---|
| 231 | nbad = 0;
|
---|
| 232 | sa_size_t n = 0;
|
---|
| 233 | size_t l = str.length();
|
---|
| 234 | if (l < 1) return(0);
|
---|
[2286] | 235 | // if ((str[0] == '#') || (str[0] == '*')) return(0);
|
---|
[1558] | 236 | size_t q = 0;
|
---|
[2286] | 237 | size_t p = 0;
|
---|
| 238 | /*
|
---|
| 239 | size_t p = str.find_first_not_of(sep);
|
---|
[1558] | 240 | if ((str[p] == '+') || (str[p] == '-')) {
|
---|
| 241 | if (p == l-1) return(0);
|
---|
| 242 | if (!isdigit(str[p+1])) return(0);
|
---|
| 243 | }
|
---|
| 244 | else if (!isdigit(str[p]) && (str[p] != '\'') && (str[p] != '(') ) return(0);
|
---|
[2286] | 245 | */
|
---|
[1558] | 246 | while(q < l) {
|
---|
[2286] | 247 | p = str.find_first_not_of(sep,q);
|
---|
[1558] | 248 | if (p >= l) break;
|
---|
| 249 | if (str[p] == '\'') { // Decodage d'un string
|
---|
| 250 | q = str.find('\'',p+1);
|
---|
| 251 | if (q < l) {
|
---|
| 252 | vecv_.push_back(MuTyV(str.substr(p+1,q-p-1)));
|
---|
| 253 | n++; q++;
|
---|
| 254 | }
|
---|
| 255 | else nbad++;
|
---|
| 256 | }
|
---|
| 257 | else if (str[p] == '(') { // Decodage d'un complex
|
---|
| 258 | q = str.find(')',p);
|
---|
| 259 | if (q < l) {
|
---|
| 260 | q++;
|
---|
| 261 | MuTyV mtv(str.substr(p,q-p));
|
---|
[2149] | 262 | complex<r_8> z = mtv.operator complex<r_8>();
|
---|
[1558] | 263 | vecv_.push_back(MuTyV(z));
|
---|
| 264 | n++;
|
---|
| 265 | }
|
---|
| 266 | else nbad++;
|
---|
| 267 | }
|
---|
| 268 | else {
|
---|
[2286] | 269 | q = str.find_first_of(sep,p);
|
---|
[2288] | 270 | if ( !isdigit(str[p]) && !(str[p] == '+')
|
---|
| 271 | && !(str[p] == '-') && !(str[p] == '.') ) { // une chaine
|
---|
[2286] | 272 | vecv_.push_back(MuTyV(str.substr(p,q-p)));
|
---|
[2288] | 273 | n++;
|
---|
[1558] | 274 | }
|
---|
| 275 | else { // C'est un nombre
|
---|
[2288] | 276 | if (str.find_first_of(".eE",p) < q) { // c'est un flottant
|
---|
[1558] | 277 | r_8 x = atof(str.substr(p,q-p).c_str());
|
---|
| 278 | vecv_.push_back(MuTyV(x));
|
---|
| 279 | }
|
---|
| 280 | else { // un entier
|
---|
| 281 | int_8 l = atol(str.substr(p,q-p).c_str());
|
---|
| 282 | vecv_.push_back(MuTyV(l));
|
---|
| 283 | }
|
---|
| 284 | n++;
|
---|
| 285 | }
|
---|
| 286 | }
|
---|
| 287 | }
|
---|
| 288 | return (n);
|
---|
| 289 | }
|
---|
| 290 |
|
---|
| 291 | //! Decodes the input ASCII stream, creating a sequence of values
|
---|
| 292 | /*! \param is : Input ASCII stream
|
---|
| 293 | \param nr : Number of non empty (or comment) lines in stream (return value)
|
---|
| 294 | \param nc : Number of columns (= ntot/nlines) (return value)
|
---|
[2286] | 295 | \param clm : Lines starting with clm character are treated as comment lines
|
---|
| 296 | \param sep : word separator in lines
|
---|
[1558] | 297 | \return Number of decoded elements
|
---|
| 298 | */
|
---|
[2286] | 299 | sa_size_t EnumeratedSequence::FillFromFile(istream& is, sa_size_t& nr, sa_size_t& nc,
|
---|
| 300 | char clm, const char* sep)
|
---|
[1550] | 301 | {
|
---|
[1558] | 302 | nr = 0;
|
---|
| 303 | nc = 0;
|
---|
| 304 | sa_size_t n = 0;
|
---|
[3572] | 305 | //char buff[256];
|
---|
[1558] | 306 | string line;
|
---|
| 307 | int nbad, nbadtot, nel;
|
---|
| 308 | nbadtot = nbad = 0;
|
---|
| 309 | while (!is.eof()) {
|
---|
[2795] | 310 | /* Reza, Juin 2005 : Remplace par getline(istream, string) - plus sur
|
---|
| 311 | is.clear();
|
---|
| 312 | is.getline(buff, 256); line += buff; nel = 0; */
|
---|
| 313 | line = "";
|
---|
| 314 | getline(is, line);
|
---|
| 315 | if (is.good() || is.eof()) {
|
---|
[2286] | 316 | if ((line.length() > 0) && (line[0]!=clm)) {
|
---|
[2752] | 317 | nel = Append(line, nbad, sep);
|
---|
[2286] | 318 | if (nel > 0) {
|
---|
| 319 | nr++; n += nel;
|
---|
| 320 | }
|
---|
| 321 | nbadtot += nbad;
|
---|
[1558] | 322 | }
|
---|
| 323 | }
|
---|
| 324 | }
|
---|
[2795] | 325 | /* Reza, Juin 2005 : plus necessaire
|
---|
[2286] | 326 | if ((line.length() > 0) && (line[0]!=clm)) {
|
---|
[2752] | 327 | nel = Append(line, nbad, sep);
|
---|
[2795] | 328 | if (nel > 0) { nr++; n += nel; }
|
---|
| 329 | nbadtot += nbad; line = ""; }
|
---|
| 330 | */
|
---|
[1558] | 331 | if (nbadtot > 0)
|
---|
| 332 | cout << "EnumeratedSequence::FillFromFile()/Warning " << nbadtot
|
---|
| 333 | << " bad match (quotes or parenthesis) in stream " << endl;
|
---|
| 334 | nc = n/nr;
|
---|
| 335 | return (n);
|
---|
[1550] | 336 | }
|
---|
| 337 |
|
---|
[894] | 338 | //////////////////////////////////////////////////////////
|
---|
[926] | 339 | /*!
|
---|
| 340 | \class SOPHYA::Range
|
---|
| 341 | \ingroup TArray
|
---|
[2917] | 342 | This class can be used to define a range of indices. Range objects are used to extract
|
---|
| 343 | sub-arrays and slices, from arrays and matrices.
|
---|
| 344 | \sa SOPHYA::TArray SOPHYA::TMatrix
|
---|
[926] | 345 | */
|
---|
| 346 |
|
---|
[894] | 347 | /*!
|
---|
[2917] | 348 | Constructor defining a range corresponding to the single index \b start
|
---|
| 349 | \param start : start=end index
|
---|
[2915] | 350 | */
|
---|
| 351 | Range::Range(sa_size_t start)
|
---|
| 352 | {
|
---|
| 353 | start_ = start;
|
---|
[2917] | 354 | end_ = start;
|
---|
| 355 | size_ = 1;
|
---|
[2915] | 356 | step_ = 1;
|
---|
| 357 | }
|
---|
| 358 |
|
---|
| 359 | /*!
|
---|
| 360 | Constructor defining defining the range of indices, from \b start to \b end
|
---|
| 361 | \param start : start index (inclusive)
|
---|
[1412] | 362 | \param end : end index (inclusive)
|
---|
[2915] | 363 | */
|
---|
| 364 | Range::Range(sa_size_t start, sa_size_t end)
|
---|
| 365 | {
|
---|
| 366 | start_ = start;
|
---|
| 367 | end_ = end;
|
---|
| 368 | if (end >= start) size_ = end-start+1;
|
---|
| 369 | else size_ = 0;
|
---|
| 370 | step_ = 1;
|
---|
| 371 | }
|
---|
[894] | 372 |
|
---|
[2915] | 373 | /*!
|
---|
| 374 | Constructor defining defining the range of indices, from \b start to \b end
|
---|
| 375 | \param start : start index (inclusive)
|
---|
| 376 | \param end : end index (inclusive)
|
---|
| 377 | \param step : step (or stride) = index increment
|
---|
| 378 | */
|
---|
| 379 | Range::Range(sa_size_t start, sa_size_t end, sa_size_t step)
|
---|
| 380 | {
|
---|
| 381 | start_ = start;
|
---|
| 382 | end_ = end;
|
---|
| 383 | step_ = (step > 0) ? step : 1;
|
---|
| 384 | if (step < 1) step = 1;
|
---|
| 385 | if (end >= start)
|
---|
| 386 | size_ = (end-start)/step_+1;
|
---|
| 387 | else size_ = 0;
|
---|
| 388 | }
|
---|
| 389 |
|
---|
| 390 | /*!
|
---|
| 391 | Define a range of indices
|
---|
| 392 | \param start : start index (inclusive)
|
---|
| 393 | \param end : end index (inclusive, used if size \<= 0 and end \>= start)
|
---|
| 394 | \param size : size (number of elements, used if \>= 1 )
|
---|
| 395 | \param step : step (or stride) = index increment
|
---|
| 396 |
|
---|
| 397 | \warning If \b size \>= 1 , \b end index computed automatically.
|
---|
| 398 | If \b size \< 1 and \b end < \b start , equivalent to \b end = Range()::lastIndex()
|
---|
[894] | 399 | */
|
---|
[1156] | 400 | Range::Range(sa_size_t start, sa_size_t end, sa_size_t size, sa_size_t step)
|
---|
[785] | 401 | {
|
---|
| 402 | start_ = start;
|
---|
| 403 | step_ = (step > 0) ? step : 1;
|
---|
[2915] | 404 | if (size > 0) { // Nb d'elements fixe
|
---|
[813] | 405 | size_ = size;
|
---|
[2917] | 406 | if ( (start == end) && (end == Range::lastIndex()) ) start_ = end_ = end;
|
---|
| 407 | else end_ = start_+(size_-1)*step_;
|
---|
[813] | 408 | }
|
---|
[2915] | 409 | else {
|
---|
| 410 | if (end >= start) { // Indice de fin fixe
|
---|
| 411 | end_ = end;
|
---|
| 412 | size_ = (end-start)/step_+1;
|
---|
| 413 | }
|
---|
| 414 | else { // rien fixe
|
---|
| 415 | size_ = 0;
|
---|
| 416 | end_ = Range::lastIndex();
|
---|
| 417 | }
|
---|
| 418 | }
|
---|
[785] | 419 | }
|
---|
| 420 |
|
---|
[804] | 421 | /*
|
---|
[2915] | 422 | Range::Range(Range const& a)
|
---|
| 423 | {
|
---|
| 424 | start_ = a.start_;
|
---|
| 425 | end_ = a.end_;
|
---|
| 426 | size_ = a.size_;
|
---|
| 427 | step_ = a.step_;
|
---|
| 428 | }
|
---|
| 429 | */
|
---|
| 430 |
|
---|
| 431 | /*!
|
---|
| 432 | This method is called to recompute index ranges, specifying the original array size
|
---|
| 433 | by the TArray<T> (or derived classes) sub array extraction methods
|
---|
| 434 | */
|
---|
| 435 | void Range::Update(sa_size_t osz)
|
---|
| 436 | {
|
---|
[2917] | 437 | if (end_ >= 0) return;
|
---|
[2915] | 438 | if (osz == 0) {
|
---|
| 439 | start_ = end_ = 0;
|
---|
| 440 | size_ = step_ = 1;
|
---|
| 441 | return;
|
---|
| 442 | }
|
---|
| 443 | if (end_ == start_) {
|
---|
| 444 | end_ = osz-1;
|
---|
| 445 | if ((size_ > 0) && (size_ <= osz/step_))
|
---|
[2917] | 446 | start_ = end_ - (size_-1)*step_;
|
---|
[2915] | 447 | else {
|
---|
| 448 | start_ = end_;
|
---|
| 449 | size_ = 1;
|
---|
| 450 | }
|
---|
| 451 | }
|
---|
| 452 | else {
|
---|
| 453 | end_ = osz-1;
|
---|
| 454 | size_ = (end_-start_)/step_+1;
|
---|
| 455 | }
|
---|
[2917] | 456 | //DBG cout << ">>> DBG/Update start=" << start_ << " end=" << end_
|
---|
| 457 | //DBG << " size=" << size_ << " step=" << step_ << endl;
|
---|
[2915] | 458 | return;
|
---|
| 459 | }
|
---|
| 460 |
|
---|
| 461 | /*
|
---|
[1156] | 462 | Range & Range::operator = (sa_size_t start)
|
---|
[785] | 463 | {
|
---|
| 464 | start_ = start;
|
---|
| 465 | size_ = 1;
|
---|
| 466 | step_ = 1;
|
---|
| 467 | return (*this);
|
---|
| 468 | }
|
---|
[804] | 469 | */
|
---|
| 470 |
|
---|
| 471 |
|
---|
[894] | 472 | //////////////////////////////////////////////////////////
|
---|
[926] | 473 | /*!
|
---|
| 474 | \class SOPHYA::IdentityMatrix
|
---|
| 475 | \ingroup TArray
|
---|
[2917] | 476 | Class to define an identity matrix. This class is mainly intented for
|
---|
| 477 | initializing TMatrix<T> objects, proportional to the identity matrix.
|
---|
[926] | 478 | */
|
---|
| 479 |
|
---|
[2917] | 480 | //! Constructor representing a square matrix (\b n x \b n) with value \b diag on the diagonal
|
---|
[1156] | 481 | IdentityMatrix::IdentityMatrix(double diag, sa_size_t n)
|
---|
[804] | 482 | {
|
---|
| 483 | size_ = n;
|
---|
| 484 | diag_ = diag;
|
---|
| 485 | }
|
---|