Changeset 850 in Sophya for trunk/SophyaLib/TArray


Ignore:
Timestamp:
Apr 10, 2000, 2:57:45 PM (25 years ago)
Author:
ansari
Message:

Corrections divers + RansomSequence - Reza 10/4/2000

Location:
trunk/SophyaLib/TArray
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/TArray/basarr.cc

    r813 r850  
    308308void BaseArray::Show(ostream& os, bool si) const
    309309{
     310  if (ndim_ < 1) {
     311    os << "\n--- " << BaseArray::InfoString() << " Unallocated Array ! " << endl;
     312    return;
     313  }
    310314  os << "\n--- " << InfoString() ;
    311315  os << " ND=" << ndim_ << " SizeX*Y*...= " ;
  • trunk/SophyaLib/TArray/sopemtx.h

    r804 r850  
    3939}
    4040
     41inline r_4 LinSolve(const TMatrix<r_4>& a, const TVector<r_4>& b, TVector<r_4>& c)
     42{
     43if(a.NCols() != b.NRows() || a.NCols() != a.NRows())
     44  throw(SzMismatchError("LinSolve(TMatrix<r_4>,TVector<r_4>) size mismatch"));
     45c = b;
     46TMatrix<r_4> a1(a);
     47return SimpleMatrixOperation<r_4>::GausPiv(a1,c);
     48}
     49
     50// Inverse d'une matrice
     51inline TMatrix<r_8> Inverse(TMatrix<r_8> const & A)
     52{
     53  return SimpleMatrixOperation<r_8>::Inverse(A);
     54}
     55
     56inline TMatrix<r_4> Inverse(TMatrix<r_4> const & A)
     57{
     58  return SimpleMatrixOperation<r_4>::Inverse(A);
     59}
     60
     61
    4162//--------------------------------------
    4263//        Linear fitting
  • trunk/SophyaLib/TArray/tarray.cc

    r813 r850  
    695695  int_4 npr = 0;
    696696  Show(os, si);
     697  if (ndim_ < 1) return;
    697698  uint_4 k0,k1,k2,k3,k4;
    698699  for(k4=0; k4<size_[4]; k4++) {
  • trunk/SophyaLib/TArray/tmatrix.cc

    r813 r850  
    1 // $Id: tmatrix.cc,v 1.4 2000-04-05 15:44:15 ansari Exp $
     1// $Id: tmatrix.cc,v 1.5 2000-04-10 12:57:44 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "machdefs.h"
     
    232232  int_4 npr = 0;
    233233  Show(os, si);
     234  if (ndim_ < 1)  return;
    234235  uint_4 kc,kr; 
    235236  for(kr=0; kr<size_[marowi_]; kr++) {
  • trunk/SophyaLib/TArray/utilarr.cc

    r813 r850  
    44#include "machdefs.h"
    55#include "utilarr.h"
     6#include "srandgen.h"
    67
    78// Classe utilitaires
     9
     10RandomSequence::RandomSequence(int typ, double m, double s)
     11{
     12  typ_ = (typ == Flat) ? Flat : Gaussian;
     13  mean_ = m;
     14  sig_ = s;
     15}
     16
     17double RandomSequence::Rand()
     18{
     19  if (typ_ == Flat)
     20    return(drandpm1()*sig_ + mean_);
     21  else return(GauRnd(mean_, sig_));
     22}
     23
     24
    825Sequence::Sequence(double start, double step, Arr_DoubleFunctionOfX f)
     26  : rseq_(RandomSequence::Gaussian)
    927{
    1028  start_ = start;
    1129  step_ = step;
    1230  myf_ = f;
     31  fgrseq_ = false;
     32}
     33
     34Sequence::Sequence(RandomSequence rseq)
     35{
     36  start_ = 0.;
     37  step_ = 1.;
     38  myf_ = NULL; 
     39  rseq_ = rseq;
     40  fgrseq_ = true;
    1341}
    1442
    1543double Sequence::operator () (uint_4 k)
    1644{
    17   double x = start_+(double)k*step_;
    18   if (myf_)  return(myf_(x));
    19   return x;
     45  if (fgrseq_) return(rseq_.Rand());
     46  else {
     47    double x = start_+(double)k*step_;
     48    if (myf_)  return(myf_(x));
     49    else return x;
     50  }
    2051}
    2152
  • trunk/SophyaLib/TArray/utilarr.h

    r813 r850  
    1616typedef float  (* Arr_FloatFunctionOfX)  (float x);
    1717
     18class RandomSequence {
     19public:
     20  enum { Gaussian = 0, Flat = 1 };
     21  RandomSequence(int typ = RandomSequence::Gaussian, double m=0., double s=1.);
     22  double Rand();
     23protected:
     24  int typ_;
     25  double mean_, sig_;
     26};
     27
     28
    1829class Sequence {
    1930public:
    2031  explicit Sequence (double start=0., double step=1., Arr_DoubleFunctionOfX f=NULL);
     32  explicit Sequence (RandomSequence rseq);
    2133  inline double & Start() { return start_; }
    2234  inline double & Step() { return step_; }
     
    2537  double start_, step_;
    2638  Arr_DoubleFunctionOfX myf_;
     39  bool fgrseq_;
     40  RandomSequence rseq_;
    2741};
    2842
Note: See TracChangeset for help on using the changeset viewer.