/*! _zssmatrix*_zcovector operator */
inline _zcovector operator*(const _zssmatrix& mat, const _zcovector& vec)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const _zssmatrix&, const _zcovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(mat.N!=vec.L){
    std::cerr << "[ERROR] operator*(const _zssmatrix&, const _zcovector&)"
              << std::endl
              << "These matrix and vector can not make a product." << std::endl
              << "Your input was (" << mat.M << "x" << mat.N << ") * ("
              << vec.L << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zcovector newvec(mat.M);
  newvec.zero();
  
  for(int c=0; c<mat.VOL; c++){
    newvec(mat.Indx[c]) +=mat.Array[c]*vec(mat.Jndx[c]);
  }
  
  mat.destroy();
  vec.destroy();
  return _(newvec);
}
Esempio n. 2
0
/*! _dssmatrix*_dcovector operator */
inline _dcovector operator*(const _dssmatrix& mat, const _dcovector& vec)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(mat.n!=vec.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector can not make a product." << std::endl
              << "Your input was (" << mat.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dcovector newvec(mat.n);
  newvec.zero();
  
  for(std::vector<dcomponent>::iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    newvec(it->i) +=it->v*vec(it->j);
    if(it->i!=it->j){
      newvec(it->j) +=it->v*vec(it->i);
    }
  }
  
  mat.destroy();
  vec.destroy();
  return _(newvec);
}
/*! zrovector*zssmatrix operator */
inline _zrovector operator*(const zrovector& vec, const zssmatrix& mat)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const zrovector&, const zssmatrix&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(vec.L!=mat.M){
    std::cerr << "[ERROR] operator*(const zrovector&, const zssmatrix&)"
              << std::endl
              << "These vector and matrix can not make a product."
              << std::endl
              << "Your input was (" << vec.L << ") * ("
              << mat.M << "x" << mat.N << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.N);
  newvec.zero();
  
  for(int c=0; c<mat.VOL; c++){
    newvec(mat.Jndx[c]) +=vec(mat.Indx[c])*mat.Array[c];
  }
  
  return _(newvec);
}
Esempio n. 4
0
/*! return its conjugated vector */
inline _zrovector conj(const zrovector& vec)
{VERBOSE_REPORT;
  zrovector newvec(vec.l);
  
  for(long i=0; i<vec.l; i++){
    newvec(i) =std::conj(vec(i));
  }
  
  return _(newvec);
}
Esempio n. 5
0
/*! return its conjugated vector */
inline _zrovector conj(const zrovector& vec)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] conj(const zrovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
  zrovector newvec(vec.L);
  for(long i=0; i<vec.L; i++){ newvec(i) =std::conj(vec(i)); }
  
  return _(newvec);
}
Esempio n. 6
0
/*! -dcovector operator */
inline _dcovector operator-(const dcovector& vec)
{VERBOSE_REPORT;
  dcovector newvec(vec.l);
  for(long i=0; i<newvec.l; i++){ newvec.array[i]=-vec.array[i]; }
  
  return _(newvec);
}
/*! zrovector+zrovector operator */
inline _zrovector operator+(const zrovector& vecA, const zrovector& vecB)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator+(const zrovector&, const zrovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(vecA.L!=vecB.L){
    std::cerr << "[ERROR] operator+(const zrovector&, const zrovector&)"
              << std::endl
              << "These two vectors can not make a sumation." << std::endl
              << "Your input was (" << vecA.L << ") + (" << vecB.L << ")."
              << std::endl;
    exit(1);
  }
  
#endif//CPPL_DEBUG
  
  zrovector newvec(vecA.L);
  for(long i=0; i<newvec.l; i++){
    newvec.array[i] =vecA.Array[i]+vecB.Array[i];
  }
  
  return _(newvec);
}
/*! _dgbmatrix*_dcovector operator */
inline _dcovector operator*(const _dgbmatrix& mat, const _dcovector& vec)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const _dgbmatrix&, const _dcovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(mat.N!=vec.L){
    std::cerr << "[ERROR] operator*(const _dgbmatrix&, const _dcovector&)"
              << std::endl
              << "These matrix and vector can not make a product." << std::endl
              << "Your input was (" << mat.M << "x" << mat.N << ") * ("
              << vec.L << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dcovector newvec(mat.M);
  dgbmv_( 'N', mat.M, mat.N, mat.KL, mat.KU, 1.0, mat.Array,
          mat.KL+mat.KU+1, vec.Array, 1, 0.0, newvec.array, 1 );
  
  mat.destroy();
  vec.destroy();
  return _(newvec);
}
Esempio n. 9
0
/*! comple*zrovector operator */
inline _zrovector operator*(const comple& d, const zrovector& vec)
{VERBOSE_REPORT;
  zrovector newvec(vec.l);
  for(long i=0; i<vec.l; i++){ newvec.array[i] =d*vec.array[i]; }
  
  return _(newvec);
}
/*! _zrovector*zgbmatrix operator */
inline _zrovector operator*(const _zrovector& vec, const zgbmatrix& mat)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const _zrovector&, const zgbmatrix&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(vec.L!=mat.M){
    std::cerr << "[ERROR] operator*(const _zrovector&, const zgbmatrix&)"
              << std::endl
              << "These vector and matrix can not make a product."
              << std::endl
              << "Your input was (" << vec.L << ") * ("
              << mat.M << "x" << mat.N << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.N);
  zgbmv_( 'T', mat.M, mat.N, mat.KL, mat.KU, std::complex<double>(1.0,0.0),
          mat.Array, mat.KL+mat.KU+1, vec.Array, 1, std::complex<double>(0.0,0.0), newvec.array, 1 );
  
  vec.destroy();
  return _(newvec);
}
/*! _zhematrix*zcovector operator */
inline _zcovector operator*(const _zhematrix& mat, const zcovector& vec)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const _zhematrix&, const zcovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
#ifdef  CPPL_DEBUG
  if(mat.N!=vec.L){
    std::cerr << "[ERROR] operator*(const _zhematrix&, const zcovector&)"
              << std::endl
              << "These matrix and vector can not make a product." << std::endl
              << "Your input was (" << mat.N << "x" << mat.N << ") * ("
              << vec.L << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zcovector newvec(mat.N);
  zhemv_( 'L', mat.N, std::complex<double>(1.0,0.0), mat.Array, mat.N,
          vec.Array, 1, std::complex<double>(0.0,0.0), newvec.array, 1 );
  
  mat.destroy();
  return _(newvec);
}
Esempio n. 12
0
template<typename T> std::vector<T> extractIndices(std::vector<T> oldvec, std::vector<size_t> indices){
	std::vector<T> newvec();
	newvec.reserve(indices.size());
	for (size_t ind : indices){
		assert(ind < oldvec.size());
		newvec.push_back(oldvec[ind]);
	}
	return newvec;
}
Esempio n. 13
0
/*! drovector*_dgsmatrix operator */
inline _drovector operator*(const drovector& vec, const _dgsmatrix& mat)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.m){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  drovector newvec(mat.n);
  newvec.zero();
  for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
    newvec(it->j) += vec(it->i)*it->v;
  }
  
  mat.destroy();
  return _(newvec);
}
Esempio n. 14
0
/*! cast to _zcovector */
inline _zcovector _dcovector::to_zcovector() const
{VERBOSE_REPORT;
  zcovector newvec(l);
  
  for(long i=0; i<l; i++){
    newvec.array[i] =comple(array[i], 0.);
  }
  
  destroy();
  return _(newvec);
}
Esempio n. 15
0
/*! -drovector operator */
inline _drovector operator-(const drovector& vec)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator-(const drovector&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
  drovector newvec(vec.L);
  for(long i=0; i<newvec.L; i++){ newvec.array[i]=-vec.Array[i]; }
  
  return _(newvec);
}
Esempio n. 16
0
/*! dgematrix%dgematrix operator */
inline _drovector operator%(const dgematrix& matA, const dgematrix& matB)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(matA.m!=matB.m || matA.n!=matB.n){
    ERROR_REPORT;
    std::cerr << "These two matrises can not make a product." << std::endl
              << "Your input was (" << matA.m << "x" << matA.n << ") % (" << matB.m << "x" << matB.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  drovector newvec( matA.n );
  newvec.zero();
  for(long j=0; j<matA.n; j++){
    for(long i=0; i<matA.m; i++){
      newvec(j) +=matA(i,j)*matB(i,j);
    }
  }
  
  return _(newvec);
}
Esempio n. 17
0
/*! zcovector*double operator */
inline _zcovector operator*(const zcovector& vec, const double& d)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator*(const zcovector&, const double&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
  zcovector newvec(vec.L);
  for(long i=0; i<vec.L; i++){ newvec.array[i] =vec.Array[i]*d; }
  
  return _(newvec);
}
Esempio n. 18
0
	int RCursorControl::getRelativePosition(lua_State* L)
	{
		ifistrue(objectExists);
		
		core::RVector2D* vector = Luna < core::RVector2D >::createNew(L);
		irr::core::position2d<cIrrNumber> pos = obj->getRelativePosition();
		cIrrVector2D newvec(pos.X,pos.Y);
		vector->setObject(newvec);
		return 1;
		
		endifisvalid();
	}
Esempio n. 19
0
/*! zcovector/std::complex<double> operator */
inline _zcovector operator/(const zcovector& vec, const std::complex<double>& d)
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] operator/(const zcovector&, const std::complex<double>&)"
            << std::endl;
#endif//CPPL_VERBOSE
  
  std::complex<double> inv_d(1./d);
  
  zcovector newvec(vec.L);
  for(long i=0; i<vec.L; i++){ newvec.array[i] =vec.Array[i]*inv_d; }
  
  return _(newvec);
}
Esempio n. 20
0
/*! dsymatrix*dcovector operator */
inline _dcovector operator*(const dsymatrix& mat, const dcovector& vec)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(mat.n!=vec.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector can not make a product." << std::endl
              << "Your input was (" << mat.n << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  dcovector newvec(mat.n);
  dsymv_( 'l', mat.n, 1.0, mat.array, mat.n, vec.array, 1, 0.0, newvec.array, 1 );
  
  return _(newvec);
}
Esempio n. 21
0
/*! drovector*dgematrix operator */
inline _drovector operator*(const drovector& vec, const dgematrix& mat)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.m){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  drovector newvec(mat.n);
  dgemv_( 'T', mat.m, mat.n, 1.0, mat.array, mat.m,
          vec.array, 1, 0.0, newvec.array, 1 );
  
  return _(newvec);
}
Esempio n. 22
0
/*! zrovector*_zgbmatrix operator */
inline _zrovector operator*(const zrovector& vec, const _zgbmatrix& mat)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(vec.l!=mat.m){
    ERROR_REPORT;
    std::cerr << "These vector and matrix can not make a product." << std::endl
              << "Your input was (" << vec.l << ") * (" << mat.m << "x" << mat.n << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zrovector newvec(mat.n);
  zgbmv_( 'T', mat.m, mat.n, mat.kl, mat.ku, comple(1.0,0.0),
          mat.array, mat.kl+mat.ku+1, vec.array, 1, comple(0.0,0.0), newvec.array, 1 );
  
  mat.destroy();
  return _(newvec);
}
Esempio n. 23
0
/*! zcovector-zcovector operator */
inline _zcovector operator-(const zcovector& vecA, const zcovector& vecB)
{   VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
    if(vecA.l!=vecB.l) {
        ERROR_REPORT;
        std::cerr << "These two vectors can not make a subtraction." << std::endl
                  << "Your input was (" << vecA.l << ") - (" << vecB.l << ")." << std::endl;
        exit(1);
    }
#endif//CPPL_DEBUG

    zcovector newvec(vecA.l);
    for(long i=0; i<newvec.l; i++) {
        newvec.array[i] =vecA.array[i]-vecB.array[i];
    }

    return _(newvec);
}
Esempio n. 24
0
/*! _zgematrix*zcovector operator */
inline _zcovector operator*(const _zgematrix& mat, const zcovector& vec)
{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(mat.n!=vec.l){
    ERROR_REPORT;
    std::cerr << "These matrix and vector can not make a product." << std::endl
              << "Your input was (" << mat.m << "x" << mat.n << ") * (" << vec.l << ")." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  zcovector newvec(mat.m);
  zgemv_( 'n', mat.m, mat.n, comple(1.0,0.0), mat.array, mat.m,
          vec.array, 1, comple(0.0,0.0), newvec.array, 1 );
  
  mat.destroy();
  return _(newvec);
}
Esempio n. 25
0
/*! cast operator to _zcovector */
inline _dcovector::operator _zcovector()
{
#ifdef  CPPL_VERBOSE
  std::cerr << "# [MARK] _dcovector::operator _zcovector()"
            << std::endl;
#endif//CPPL_VERBOSE
  
  zcovector newvec(L);
  for(long i=0; i<L; i++){
    newvec.array[i] =std::complex<double>(Array[i],0.0);
  }
  
#ifdef  CPPL_DEBUG
  std::cerr << "# [NOTE] _dcovector::operator _zcovector() "
            << "A new casted matrix at " << newvec.array 
            << " has been made." << std::endl;
#endif//CPPL_DEBUG
  
  destroy();
  return _(newvec);
}
Esempio n. 26
0
Acad::ErrorStatus
AsdkSmiley::moveGripPointsAt(
    const AcDbIntArray& indices,
    const AcGeVector3d& offset)
{
    assertWriteEnabled();

    AcGePoint3dArray eyearray;
    AcGePoint3d oldquad, newquad, newmouthcenter, newmouthbottom,
                smilecen, startpt, endpt, midpt, newpt;
    AcGeVector3d vecstart(0,0,0), vecend(0,0,0), newvec(0,0,0);

    eyes( eyearray );
    for( int i = 0; i < indices.length(); i++ ) {
        int idx = indices[i];
        switch( idx ) {

        // Stretch smiley center
        //
        case 0:
            setCenter( center() + offset );
            continue;

        // Stretch smiley radius
        //
        case 1:
            oldquad = center() + AcGeVector3d( radius(), 0, 0 );
            break;
        case 2:
            oldquad = center() + AcGeVector3d( 0, radius(), 0 );
            break;
        case 3:
            oldquad = center() - AcGeVector3d( radius(), 0, 0 );
            break;
        case 4:
            oldquad = center() - AcGeVector3d( 0, radius(), 0 );
            break;

        // Stretch smiley mouth
        //
        case 5:
            // Left hand edge of mouth
            //
            setMouthLeft( mouthLeft() + offset );
            ensureRadius();

            continue;

        case 6:
            // Right hand edge of mouth
            //
            setMouthRight( mouthRight() + offset );
            ensureRadius();

            continue;

        case 7:
            // Middle mouth chord
            //
            setMouth( mouthLeft() + offset, mouthBottom() + offset, mouthRight() + offset );
            ensureRadius();

            continue;

        case 8:
            // Bottom of mouth arc
            //
            setMouthBottom( mouthBottom() + offset );
            ensureRadius();

            continue;

        // Stretch smiley eyes
        //
        default:
            if(( eyearray.length() * 5 ) + 9 > idx ){
                
                // Get eye number, extracting it from the array
                //
                int eyepos = (int)(( idx - 9 ) / 5 );
                AcGePoint3d eyecen = eyearray.at( eyepos );
                
                // Handle the grip for the eye
                //
                int subidx = idx - 9;
                while ( subidx >= 5 ){ subidx -= 5; }
                switch( subidx ){

                // Stretch eye center
                //
                case 0:
                    // Keep the minimum eye height at zero
                    //
                    if( meyesheight+offset[Y] < 0 )
                        setEyesHeight( 0 );
                    else
                        setEyesHeight( meyesheight + offset[Y] );

                    // Keep the eyes from overlapping
                    //
                    if( eyecen[X] < center()[X] ){    // left eye
                        if( meyesapart - ( offset[X] * 2 ) < meyesize * 2 )
                            setEyesApart( meyesize * 2 );
                        else
                            setEyesApart( meyesapart - ( offset[X] * 2 ));
                    }
                    else {                          // right eye
                        if( meyesapart + ( offset[X] * 2 ) < meyesize * 2 )
                            setEyesApart( meyesize * 2 );
                        else
                            setEyesApart( meyesapart + ( offset[X] * 2));
                    }
                    ensureRadius();
                    continue;

                // Stretch eye radius
                //
                case 1:
                    oldquad = eyecen + AcGeVector3d( meyesize, 0, 0 );
                    break;
                case 2:
                    oldquad = eyecen + AcGeVector3d( 0, meyesize, 0 );
                    break;
                case 3:
                    oldquad = eyecen - AcGeVector3d( meyesize, 0, 0 );
                    break;
                case 4:
                    oldquad = eyecen - AcGeVector3d( 0, meyesize, 0 );
                    break;
                }
                newquad = oldquad + offset;
                
                // Keep eyes from touching
                //
                if( newquad.distanceTo( eyecen ) > meyesapart / 2 )
                    setEyeSize( meyesapart / 2 );
                else
                    setEyeSize( newquad.distanceTo( eyecen ));
                ensureRadius();
            }
            continue;
        }
        newquad = oldquad + offset;
        scaleRadius( newquad.distanceTo( center() ));
    }

    return Acad::eOk;
}
Esempio n. 27
0
void EC_Gizmo::Manipulate(const QVariant &datum)
{
    for(int i = 0; i < attributes_.size(); i++) {
        IAttribute * attr = attributes_.at(i);
        if(attr->GetNameString() == "Transform") {
            Attribute<Transform>* attribute = dynamic_cast<Attribute<Transform> *>(attr);
            if(attribute && datum.type()==QVariant::Vector3D) {
                Transform trans = attribute->Get();
                QVector3D vec = datum.value<QVector3D>();
                QString subproperty = subproperties_.at(i);
                if (subproperty=="scale") {
                    trans.scale.x += vec.x();
                    trans.scale.y += vec.y();
                    trans.scale.z += vec.z();
                }
                else if (subproperty=="rotation") {
                    trans.rotation.x += vec.x();
                    trans.rotation.y += vec.y();
                    trans.rotation.z += vec.z();
                }
                else { /* by default do position */
                    trans.position.x += vec.x();
                    trans.position.y += vec.y();
                    trans.position.z += vec.z();
                }
                attribute->Set(trans, AttributeChange::Default);
            }
        } else {
            switch(datum.type()) {
                case QVariant::Double:
                    {
                        float value = datum.toFloat();
                        Attribute<float> *attribute = dynamic_cast<Attribute<float> *>(attr);
                        if(attribute)
                            attribute->Set(attribute->Get() + value, AttributeChange::Default);
                    }
                    break;
                case QVariant::Int:
                    {
                        int value = datum.toInt();
                        Attribute<int> *attribute = dynamic_cast<Attribute<int> *>(attr);
                        if(attribute)
                            attribute->Set(attribute->Get() + value, AttributeChange::Default);
                    }
                    break;
                case QVariant::Bool:
                    {
                        bool value = datum.toBool();
                        Attribute<bool> *attribute = dynamic_cast<Attribute<bool> *>(attr);
                        if(attribute)
                            attribute->Set(value, AttributeChange::Default);
                    }
                    break;
                case QVariant::Vector3D:
                    {
                        QVector3D vec = datum.value<QVector3D>();
                        Attribute<QVector3D> *attribute = dynamic_cast<Attribute<QVector3D> *>(attr);
                        if(attribute) {
                            attribute->Set(attribute->Get() + vec, AttributeChange::Default);
                        } else {
                            Attribute<Vector3df> *attribute = dynamic_cast<Attribute<Vector3df> *>(attr);
                            Vector3df newvec(vec.x(), vec.y(), vec.z());
                            if(attribute) {
                                attribute->Set(attribute->Get() + newvec, AttributeChange::Default);
                            }
                        }
                    }
                    break;
            }
        }
    }
}