Beispiel #1
0
 NLDRNeighborList& operator=(const NLDRNeighborList& nn)
 {
     if (&nn==this) return *this;
     nlist.resize(nn.nlist.size()); nlist=nn.nlist;
     npoint.resize(nn.npoint.size()); npoint=nn.npoint;
     opts=nn.opts;
 }
Beispiel #2
0
void RandomTestOctic(std::valarray<T> & coefficients, std::valarray<T> & solutions)
{
	solutions.resize(8);
	for (int ii=0; ii<8; ii++)
		solutions[ii] = Random<T>::Generate();


	const T& s0 = solutions[0];
	const T& s1 = solutions[1];
	const T& s2 = solutions[2];
	const T& s3 = solutions[3];
	const T& s4 = solutions[4];
	const T& s5 = solutions[5];
	const T& s6 = solutions[6];
	const T& s7 = solutions[7];

	coefficients.resize(8); // omitting the 1, so it's monic

	coefficients[0] = s0*s1*s2*s3*s4*s5*s6*s7;
	coefficients[1] = - s7*(s6*(s5*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) + s0*s1*s2*s3*s4) + s0*s1*s2*s3*s4*s5) - s0*s1*s2*s3*s4*s5*s6;
	coefficients[2] = s7*(s6*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s5*(s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) + s5*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) + s0*s1*s2*s3*s4) + s6*(s5*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) + s0*s1*s2*s3*s4) + s0*s1*s2*s3*s4*s5;
	coefficients[3] = - s7*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s5*(s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s6*(s5*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) + s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) - s6*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s5*(s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) - s5*(s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3) - s0*s1*s2*s3*s4;
	coefficients[4] = s7*(s5*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) + s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s6*(s2*(s0 + s1) + s0*s1 + s5*(s0 + s1 + s2 + s3 + s4) + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s4*(s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s5*(s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s6*(s5*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) + s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) + s3*(s2*(s0 + s1) + s0*s1) + s0*s1*s2) + s0*s1*s2*s3;
	coefficients[5] = - s5*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) - s4*(s2*(s0 + s1) + s0*s1 + s3*(s0 + s1 + s2)) - s7*(s2*(s0 + s1) + s0*s1 + s5*(s0 + s1 + s2 + s3 + s4) + s3*(s0 + s1 + s2) + s6*(s0 + s1 + s2 + s3 + s4 + s5) + s4*(s0 + s1 + s2 + s3)) - s6*(s2*(s0 + s1) + s0*s1 + s5*(s0 + s1 + s2 + s3 + s4) + s3*(s0 + s1 + s2) + s4*(s0 + s1 + s2 + s3)) - s3*(s2*(s0 + s1) + s0*s1) - s0*s1*s2;
	coefficients[6] = s2*(s0 + s1) + s0*s1 + s7*(s0 + s1 + s2 + s3 + s4 + s5 + s6) + s5*(s0 + s1 + s2 + s3 + s4) + s3*(s0 + s1 + s2) + s6*(s0 + s1 + s2 + s3 + s4 + s5) + s4*(s0 + s1 + s2 + s3);
	coefficients[7] = - s0 - s1 - s2 - s3 - s4 - s5 - s6 - s7;
}
Beispiel #3
0
	AsebaNode()
	{
		// create VM
		vm.nodeId = 0;
		bytecode.resize(512);
		vm.bytecode = &bytecode[0];
		vm.bytecodeSize = bytecode.size();
		
		stack.resize(64);
		vm.stack = &stack[0];
		vm.stackSize = stack.size();
		
		vm.variables = reinterpret_cast<sint16 *>(&variables);
		vm.variablesSize = sizeof(variables) / sizeof(sint16);
		
		AsebaVMInit(&vm);
		
		// fill description accordingly
		d.name = L"testvm";
		d.protocolVersion = ASEBA_PROTOCOL_VERSION;
		
		d.bytecodeSize = vm.bytecodeSize;
		d.variablesSize = vm.variablesSize;
		d.stackSize = vm.stackSize;
		
		/*d.namedVariables.push_back(TargetDescription::NamedVariable("id", 1));
		d.namedVariables.push_back(TargetDescription::NamedVariable("source", 1));
		d.namedVariables.push_back(TargetDescription::NamedVariable("args", 32));*/
	}
Beispiel #4
0
 NLDRLLEReport& operator=(const NLDRLLEReport& nr)
 {
     if (&nr==this) return *this;
     hd_errors.resize(nr.hd_errors.size()); hd_errors=nr.hd_errors;  hd_error=nr.hd_error;
     ld_errors.resize(nr.ld_errors.size()); ld_errors=nr.ld_errors;  ld_error=nr.ld_error;
     deval.resize(nr.deval.size()); deval=nr.deval;  dp1eval=nr.dp1eval;
     return *this;
 }
Beispiel #5
0
void rfsum(const std::valarray<tblapack::complex>& p1, const std::valarray<tblapack::complex>& q1,
           const std::valarray<tblapack::complex>& p2, const std::valarray<tblapack::complex>& q2,
           std::valarray<tblapack::complex>& p, std::valarray<tblapack::complex>& q)
{
    //given the coefficients of the polynomials in P1/Q1+P2/Q2 computes the coefficients
    //in the polynomials in P/Q (the reduced sum). NO SIMPLIFICATIONS ARE DONE (OF COURSE)
    q.resize(q1.size()+q2.size()-1); q=0.;
    for (int i=0; i<q1.size(); i++) for (int j=0; j<q2.size(); j++) q[i+j]+=q1[i]*q2[j];
            
    if (p1.size()==0 || (p2.size()>0 && q1.size()+p2.size()>p1.size()+q2.size())) p.resize(q1.size()+p2.size()-1);
    else if (p1.size()>0) p.resize(p1.size()+q2.size()-1);
    else p.resize(0);
    for (int i=0; i<q1.size(); i++) for (int j=0; j<p2.size(); j++) p[i+j]+=q1[i]*p2[j];
    for (int i=0; i<q2.size(); i++) for (int j=0; j<p1.size(); j++) p[i+j]+=q2[i]*p1[j];
}
Beispiel #6
0
 void set_points(const FMatrix<double>& nP, const FMatrix<double>& np, const std::valarray<double>& nw=std::valarray<double>(0))
 {
     if ((n=nP.rows())<1 || (D=nP.cols())<1) ERROR("Hi-dimensional array has inconsistent sizes.");
     if (np.rows()!=n || (d=np.cols())<1 || d>D) ERROR("Low-dimensional array has inconsistent sizes.");
     P=nP; p=np; ftainted=true;
     w.resize(n); if (nw.size()==0) w=1.0; else w=nw;
 }
Beispiel #7
0
        void diff(const std::valarray<double>& a, const std::valarray<double>& b, std::valarray<double>& c) const
        {
#ifdef DEBUG
            if (a.size()!=b.size()) ERROR("Vector size mismatch in distance.");
#endif
            c.resize(a.size()); pdiff(&a[0], &b[0], &c[0], a.size()); 
        }
Beispiel #8
0
	AsebaNode()
	{
		// setup variables
		vm.nodeId = 1;
		
		bytecode.resize(512);
		vm.bytecode = &bytecode[0];
		vm.bytecodeSize = bytecode.size();
		
		stack.resize(64);
		vm.stack = &stack[0];
		vm.stackSize = stack.size();
		
		vm.variables = reinterpret_cast<sint16 *>(&variables);
		vm.variablesSize = sizeof(variables) / sizeof(sint16);
	}
Beispiel #9
0
void halve(std:: valarray<float> &imap, int inx, int iny, std:: valarray<float> &omap) {
    if(inx % 2) {
        // it is odd
        std:: cout << " nx of the input map is odd " << std:: endl;
        std:: cout << " I cannot process ... I will STOP here!!! " << std:: endl;
        exit(1);
    }
    if(iny % 2) {
        // it is odd
        std:: cout << " ny of the input map is odd " << std:: endl;
        std:: cout << " I cannot process ... I will STOP here!!! " << std:: endl;
        exit(1);
    }

    int nx = inx/2;
    int ny = iny/2;

    omap.resize(nx*ny);
    for(int i=0; i<nx; i++) for(int j=0; j<ny; j++) {
            omap[i+nx*j] = (imap[(2*i)+inx*(2*j)] +
                            imap[(2*i+1)+inx*(2*j)] +
                            imap[(2*i)+inx*(2*j+1)] +
                            imap[(2*i+1)+inx*(2*j+1)])/4;

        }
}
inline
void DMatrix::resize(size_type rows, size_type cols, value_type val)
{
  v_.resize(rows*cols,val);
  v_ = val;
  rows_ = rows;
}
Beispiel #11
0
int find_histogram(const std::valarray<T>& vol, std::valarray<int>& hist, unsigned int bins, 
		   T& min, T& max)
{
  // size and zero the histogram
  hist.resize(bins); hist = 0;

  if(min == max) { min = vol.min(); max = vol.max(); }

  int validsize(-1);

  if(min != max) {
    double fA = bins / double(max - min);
    double fB = (bins * -min) / double(max - min);
    
    validsize = 0;

    for(unsigned int i = 0; i < vol.size(); ++i) {
      unsigned int idx = unsigned(fA * vol[i] + fB);
      ++hist[ std::max(unsigned(0), std::min(idx, bins - 1)) ];
      ++validsize;
    }      
  }

  return validsize;
}
Beispiel #12
0
 frame& operator=(const frame& nf) 
 {
     if (&nf==this) return *this;
     nat=nf.nat; comment=nf.comment; 
     ats.resize(nf.ats.size()); ats=nf.ats;
     return *this;
 }
Beispiel #13
0
void GLEABC::get_evA(std::valarray<tblapack::complex>& ra)
{
    if (!fr_eva)
    {
        EigenDecomposition(A, O, O1, a); fr_eva=true;
    }
    
    ra.resize(a.size()); ra=a;
}
void KinematicCarModel::ode(const ob::State *state, const oc::Control *control, std::valarray<double> &dstate) const
{
	const double *u = control->as<oc::RealVectorControlSpace::ControlType>()->values;
	const double theta = state->as<ob::SE2StateSpace::StateType>()->getYaw();

	dstate.resize(3);
	dstate[0] = u[0] * cos(theta);
	dstate[1] = u[0] * sin(theta);
	dstate[2] = u[0] * tan(u[1]) / carLength_;
}
Beispiel #15
0
  //! Loading for std::valarray arithmetic types, using binary serialization, if supported
  template <class Archive, class T> inline
  typename std::enable_if<traits::is_input_serializable<BinaryData<T>, Archive>::value
                          && std::is_arithmetic<T>::value, void>::type
  CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::valarray<T> & valarray )
  {
    size_type valarraySize;
    ar( make_size_tag( valarraySize ) );

    valarray.resize( static_cast<std::size_t>( valarraySize ) );
    ar( binary_data( &valarray[0], static_cast<std::size_t>( valarraySize ) * sizeof(T) ) );
  }
//! Loading for std::valarray all other types
template<class Archive, class T> inline typename std::enable_if<
		!traits::is_input_serializable<BinaryData<T>, Archive>::value
				|| !std::is_arithmetic<T>::value, void>::type CEREAL_LOAD_FUNCTION_NAME(
		Archive & ar, std::valarray<T> & valarray) {
	size_type valarraySize;
	ar(make_size_tag(valarraySize));

	valarray.resize(static_cast<size_t>(valarraySize));
	for (auto && v : valarray)
		ar(v);
}
Beispiel #17
0
void load( Archive & ar, STD::valarray<U> &t,  const unsigned int /*file_version*/ )
{
    collection_size_type count;
    ar >> BOOST_SERIALIZATION_NVP(count);
    t.resize(count);
    if (t.size()){
        // explict template arguments to pass intel C++ compiler
        ar >> serialization::make_array<U, collection_size_type>(
            static_cast<U *>( boost::addressof(t[0]) ),
            count
        );
    }
Beispiel #18
0
//
// Convert an array of null-terminated strings to an array of 64-byte words
// with proper MD5 padding
//
void md5_prep_array(std::valarray<char> &paddedWords, const std::vector<std::string> &words)
{
	paddedWords.resize(64 * words.size());
	paddedWords = 0;

	for(uint i = 0; i != words.size(); i++)
	{
		char *w = &paddedWords[i*64];
		strncpy(w, words[i].c_str(), 56);
		md5_prep(w);
	}
}
Beispiel #19
0
	virtual void incomingData(Dashel::Stream *stream)
	{
		uint16 temp;
		uint16 len;
		
		stream->read(&temp, 2);
		len = bswap16(temp);
		stream->read(&temp, 2);
		lastMessageSource = bswap16(temp);
		lastMessageData.resize(len+2);
		stream->read(&lastMessageData[0], lastMessageData.size());
		
		AsebaProcessIncomingEvents(&vm);
	}
Beispiel #20
0
static std::size_t
next_index (const std::gslice &gsl, std::valarray<std::size_t> &factors)
{
    const std::size_t                start    = gsl.start ();
    const std::valarray<std::size_t> asizes   = gsl.size ();
    const std::valarray<std::size_t> astrides = gsl.stride ();

    const std::size_t ndims = asizes.size ();

    std::size_t inx = ndims;

    if (0 == factors.size ()) {
        factors.resize (ndims);

        return start;
    }

    while (inx && factors [inx - 1] == asizes [inx - 1] - 1)
        --inx;

    if (0 == inx) {
        factors = 0;

        return start;
    }

    ++factors [inx - 1];

    if (inx < factors.size ()) {
        for (std::size_t i = inx; i != ndims; ++i)
            factors [i] = 0;
    }
    else
        inx = factors.size ();

    std::size_t index = start;

    for (std::size_t i = 0; i != inx; ++i)
        index += factors [i] * astrides [i];

    return index;
}
Beispiel #21
0
 void csv2floats(const std::string&  istr, std::valarray<double>& vv)
 {
     std::vector<double> vl(0);
     vl.clear(); std::string ls=istr;
     int pos=0;
     while( (pos = ls.find_first_of(',')) != ls.npos )
     {
         if(pos > 0)
         {
             vl.push_back(str2float(ls.substr(0,pos)));
         }
         ls=ls.substr(pos+1);
     }
     if(ls.length() > 0)
     {
         vl.push_back(str2float(ls));
     }
     vv.resize(vl.size()); //copies onto a valarray
     for (int k=0; k<vl.size(); k++) vv[k]=vl[k];
 }
Beispiel #22
0
bool nest::ac_poisson_generator::
Parameters_::extract_array_(const DictionaryDatum &d, 
			    const std::string& dname,
			    std::valarray<double>& data) const
{
  if ( d->known(dname) )
  {
    ArrayDatum *ad = dynamic_cast<ArrayDatum *>((*d)[dname].datum());
    if ( ad == 0 )
      throw BadProperty();

    const size_t nd = ad->size();
    data.resize(nd);
    for ( size_t n = 0 ; n < nd ; ++n )
      {
	data[n] = getValue<double>((*ad)[n]);
      }

    return true;
  }
  else
    return false;
}
Beispiel #23
0
 void get_gradient(std::valarray<double>& rv) const {rv.resize(vg.size()); rv=vg; }
Beispiel #24
0
 void eigen_hermitian( const Complex_Matrix1& A, Complex_Matrix2& V, std::valarray<T>& Lambda, const T eps = T( 1.0e-10 ) )
 {
     Lambda.resize( A.row() );
     return eigen_hermitian_impl( A, V, Lambda.begin(), eps);
 }
Beispiel #25
0
 std::size_t eigen_jacobi( const Matrix1& A, Matrix2& V, std::valarray<T>& Lambda, const T eps = T( 1.0e-10 ) )
 {
     Lambda.resize( A.row() );
     return eigen_jacobi( A, V, Lambda.begin(), eps);
 }
Beispiel #26
0
 std::size_t cyclic_eigen_jacobi( const Matrix1& A, Matrix2& V, std::valarray<T>& Lambda, std::size_t const max_rot = 80, const T eps = T( 1.0e-10 ) )
 {
     Lambda.resize( A.row() );
     return cyclic_eigen_jacobi( A, V, Lambda.begin(), max_rot, eps );
 }
inline
void DMatrix::free() {
  v_.resize(0);
  rows_ = 0;
}
Beispiel #28
0
 NLDRMetricSphere& operator= (const NLDRMetricSphere& no) 
 { if (&no==this) return *this; periods.resize(no.periods.size()); periods=no.periods; }
Beispiel #29
0
 void get_points(std::valarray<std::valarray<double> >& nP, std::valarray<std::valarray<double> >& np) 
 { 
     nP.resize(n); np.resize(n); 
     for (unsigned long i=0; i<n; ++i) { nP[i].resize(D); for (unsigned long h=0; h<D; ++h) nP[i][h]=P(i,h); }
     for (unsigned long i=0; i<n; ++i) { np[i].resize(d); for (unsigned long h=0; h<d; ++h) np[i][h]=p(i,h); }
 }
Beispiel #30
0
 void get_vars(std::valarray<double>& rv) const { rv.resize(vx.size()); rv=vx; }