template<typename VectorType> void lpNorm(const VectorType& v)
{
  VectorType u = VectorType::Random(v.size());

  VERIFY_IS_APPROX(u.template lpNorm<Infinity>(), u.cwise().abs().maxCoeff());
  VERIFY_IS_APPROX(u.template lpNorm<1>(), u.cwise().abs().sum());
  VERIFY_IS_APPROX(u.template lpNorm<2>(), ei_sqrt(u.cwise().abs().cwise().square().sum()));
  VERIFY_IS_APPROX(ei_pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.cwise().abs().cwise().pow(5).sum());
}
double mahadist(const vtkMeshModel* model, vtkPoint targetPt, vtkPoint meanPt) {
    MatrixType cov = model->GetCovarianceAtPoint(meanPt, meanPt);
    int pointDim =3;
    VectorType x = VectorType::Zero(pointDim);
    for (unsigned d = 0; d < pointDim; d++) {
      x(d) = targetPt[d] - meanPt[d];
    }
    return x.transpose() * cov.inverse() * x;
}
 /// After serial solve, distribute solution
 void p_serialSolutionDist(VectorType& x) const
 {
   BOOST_ASSERT(!p_valueBuffer.empty());
   IdxType lo, hi;
   x.localIndexRange(lo, hi);
   p_serialSolution->getElementRange(lo, hi, &p_valueBuffer[0]);
   x.setElementRange(lo, hi, &p_valueBuffer[0]);
   x.ready();
 }
VectorType conjVector(const VectorType & v){
  VectorType result(v.dimension());
  typename VectorType::const_iterator b = v.begin(), e = v.end();
  typename VectorType::iterator  r = result.begin();
  while(b!=e){
    *r = conj(*b);
    ++r; ++b;
  }
  return result;
}
 std::vector<typename SetType::VectorType> getCorners(const SetType & set) {
   typedef typename SetType::VectorType VectorType;
   std::vector<VectorType> cor;
   VectorType v = set.get_r();
   corners(v, set.get_r(), 0, v.dimension(), cor);
   for(typename std::vector<VectorType>::iterator it = cor.begin(); it != cor.end(); ++it){
     *it = set.get_x() + set.get_C() * set.get_r0() + set.get_B() * *it;
   }
   return cor;
 }
Exemple #6
0
template<typename VectorType> void lpNorm(const VectorType& v)
{
  using std::sqrt;
  VectorType u = VectorType::Random(v.size());

  VERIFY_IS_APPROX(u.template lpNorm<Infinity>(), u.cwiseAbs().maxCoeff());
  VERIFY_IS_APPROX(u.template lpNorm<1>(), u.cwiseAbs().sum());
  VERIFY_IS_APPROX(u.template lpNorm<2>(), sqrt(u.array().abs().square().sum()));
  VERIFY_IS_APPROX(numext::pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.array().abs().pow(5).sum());
}
Pped2Set<MatrixType>::Pped2Set(const VectorType& the_x)
  : m_x(the_x),
    m_r(the_x.dimension()),
    m_r0(the_x.dimension()),
    m_B(MatrixType::Identity(the_x.dimension())),
    m_C(MatrixType::Identity(the_x.dimension())) {

  m_r.clear();
  split(m_x,m_r0);
}
CovarianceEstimatorInfo CovarianceEstimator::GetParamsMsg() const
{
	CovarianceEstimatorInfo info;
	info.source_name = _sourceName;
	VectorType params = _params->GetParamsVec();
	info.parameters.resize( params.size() );
	// GetVectorView( info.parameters ) = params;
	SerializeMatrix( params, info.parameters );
	return info;
}
	bool try_get(T* &result) {
		if (sem_trywait(&_count) == 0) {
			std::lock_guard<Lock> l(_lock);
		
			result = _data.back();
			_data.pop_back();
			return true;
		}
		return false;
	}
Exemple #10
0
 void printvector(VectorType const & vec)
 {
   #ifdef VIENNACL_AMG_DEBUGBENCH
   for (typename VectorType::const_iterator iter = vec.begin(); iter != vec.end(); ++iter)
   {
     std::cout << *iter << " ";
   }
   std::cout << std::endl;
   #endif
 }
C1AffineSet<MatrixType,Policies>::C1AffineSet(const VectorType& x, const MatrixType& B, const VectorType& r, ScalarType t)
  : SetType(
      x+B*r,
      VectorType(x.dimension()),
      MatrixType::Identity(x.dimension()),
      MatrixType(x.dimension(),x.dimension()),
      t),
    C0BaseSet(x, B, r),
    C1BaseSet(x.dimension())
{}
Exemple #12
0
Selector selectUnion( const VectorType & union_vector )
{
  Selector selector;
  if (union_vector.size() > 0) {
    selector = dereference_if_pointer(union_vector[0]);
    for (unsigned i = 1 ; i < union_vector.size() ; ++i) {
      selector |= dereference_if_pointer(union_vector[i]);
    }
  }
  return selector;
}
 //FIXME: These need to be implemented
 virtual void printTuple(std::ostream &out, size_t i, char delimiter = ',')
 {
   SharedVectorType sharedVec = _data[i];
   VectorType* vec = sharedVec.get();
   size_t size = vec->size();
   out << size;
   for(size_t i=0;i<size;i++)
   {
     out << delimiter << vec->at(i);
   }
 }
Exemple #14
0
void SolidFace3D::CalculateRightHandSide(VectorType& rRightHandSideVector,
                                         ProcessInfo& r_process_info)
{
    const unsigned int number_of_nodes = GetGeometry().size();
    unsigned int MatSize = number_of_nodes * 3;
    
    if (rRightHandSideVector.size() != MatSize)
    {
        rRightHandSideVector.resize(MatSize, false);
    }
    rRightHandSideVector = ZeroVector(MatSize);
    
    std::vector<SphericParticle*>& rNeighbours = this->mNeighbourSphericParticles;
    
    for (unsigned int i=0; i<rNeighbours.size(); i++)
    {
        if(rNeighbours[i]->Is(BLOCKED)) continue; //Inlet Generator Spheres are ignored when integrating forces.
        
        std::vector<DEMWall*>& rRFnei = rNeighbours[i]->mNeighbourRigidFaces;
                
        for (unsigned int i_nei = 0; i_nei < rRFnei.size(); i_nei++)
        {
            int Contact_Type = rNeighbours[i]->mContactConditionContactTypes[i_nei];
            
            if ( ( rRFnei[i_nei]->Id() == this->Id() ) && (Contact_Type > 0 ) )
            {
                
                array_1d<double, 4> weights_vector = rNeighbours[i]->mContactConditionWeights[i_nei];
                double weight = 0.0;
                
                double ContactForce[3] = {0.0};

                const array_1d<double, 3>& neighbour_rigid_faces_contact_force = rNeighbours[i]->mNeighbourRigidFacesTotalContactForce[i_nei];

                ContactForce[0] = neighbour_rigid_faces_contact_force[0];
                ContactForce[1] = neighbour_rigid_faces_contact_force[1];
                ContactForce[2] = neighbour_rigid_faces_contact_force[2];

                for (unsigned int k=0; k< number_of_nodes; k++)
                {
                    weight = weights_vector[k];
  
                    unsigned int w =  k * 3;

                    rRightHandSideVector[w + 0] += -ContactForce[0] * weight;
                    rRightHandSideVector[w + 1] += -ContactForce[1] * weight;
                    rRightHandSideVector[w + 2] += -ContactForce[2] * weight;
                }
                
            }//if the condition neighbour of my sphere neighbour is myself.
        }//Loop spheres neighbours (condition)
    }//Loop condition neighbours (spheres)
}//CalculateRightHandSide
Exemple #15
0
void deep_network::set_parameter(const VectorType &parameter_)
{
    int start_idx = 0;
    for (auto & layer : this->layers)
    {
        layer.W = Map<const MatrixType>(parameter_.data()+ start_idx,layer.get_input_dim(),layer.get_output_dim()) ;
        start_idx += layer.get_input_dim()  * layer.get_output_dim();
        layer.b = Map<const VectorType>(parameter_.data()+ start_idx, layer.get_output_dim());
        start_idx += layer.get_output_dim();
    }

}
unsigned X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy,
                                           unsigned Alignment,
                                           unsigned AddressSpace) {
  VectorType *SrcVTy = dyn_cast<VectorType>(SrcTy);
  if (!SrcVTy)
    // To calculate scalar take the regular cost, without mask
    return getMemoryOpCost(Opcode, SrcTy, Alignment, AddressSpace);

  unsigned NumElem = SrcVTy->getVectorNumElements();
  VectorType *MaskTy =
    VectorType::get(Type::getInt8Ty(getGlobalContext()), NumElem);
  if ((Opcode == Instruction::Load && !isLegalMaskedLoad(SrcVTy, 1)) ||
      (Opcode == Instruction::Store && !isLegalMaskedStore(SrcVTy, 1)) ||
      !isPowerOf2_32(NumElem)) {
    // Scalarization
    unsigned MaskSplitCost = getScalarizationOverhead(MaskTy, false, true);
    unsigned ScalarCompareCost =
      getCmpSelInstrCost(Instruction::ICmp,
                         Type::getInt8Ty(getGlobalContext()), NULL);
    unsigned BranchCost = getCFInstrCost(Instruction::Br);
    unsigned MaskCmpCost = NumElem * (BranchCost + ScalarCompareCost);

    unsigned ValueSplitCost =
      getScalarizationOverhead(SrcVTy, Opcode == Instruction::Load,
                               Opcode == Instruction::Store);
    unsigned MemopCost =
        NumElem * BaseT::getMemoryOpCost(Opcode, SrcVTy->getScalarType(),
                                         Alignment, AddressSpace);
    return MemopCost + ValueSplitCost + MaskSplitCost + MaskCmpCost;
  }

  // Legalize the type.
  std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(SrcVTy);
  unsigned Cost = 0;
  if (LT.second != TLI->getValueType(SrcVTy).getSimpleVT() &&
      LT.second.getVectorNumElements() == NumElem)
    // Promotion requires expand/truncate for data and a shuffle for mask.
    Cost += getShuffleCost(TTI::SK_Alternate, SrcVTy, 0, 0) +
            getShuffleCost(TTI::SK_Alternate, MaskTy, 0, 0);

  else if (LT.second.getVectorNumElements() > NumElem) {
    VectorType *NewMaskTy = VectorType::get(MaskTy->getVectorElementType(),
                                            LT.second.getVectorNumElements());
    // Expanding requires fill mask with zeroes
    Cost += getShuffleCost(TTI::SK_InsertSubvector, NewMaskTy, 0, MaskTy);
  }
  if (!ST->hasAVX512())
    return Cost + LT.first*4; // Each maskmov costs 4

  // AVX-512 masked load/store is cheapper
  return Cost+LT.first;
}
/**
 * calculates this contact element's local contributions
 */
void MasterContactPoint2D::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix,
        VectorType& rRightHandSideVector,
        ProcessInfo& rCurrentProcessInfo)
{
    unsigned int ndof = GetGeometry().size()*2;
    if( rRightHandSideVector.size() != ndof )
        rRightHandSideVector.resize(ndof,false);
    rRightHandSideVector = ZeroVector(ndof);
    if( rLeftHandSideMatrix.size1() != ndof )
        rLeftHandSideMatrix(ndof,ndof);
    rLeftHandSideMatrix = ZeroMatrix(ndof,ndof);

}
inline
void StackContextBase<TSuperClass>::setSlotVariable(const VariableSlotID slot,
                                                    const UnitType &newValue,
                                                    VectorType &container) const
{
    if(slot < container.size())
        container.replace(slot, newValue);
    else
    {
        container.resize(slot + 1);
        container.replace(slot, newValue);
    }
}
Exemple #19
0
size_t
ChromeHangAnnotations::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
  size_t result = sizeof(mAnnotations) +
                  mAnnotations.capacity() * sizeof(AnnotationType);
  for (IteratorType i = mAnnotations.begin(), e = mAnnotations.end(); i != e;
       ++i) {
    result += i->first.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
    result += i->second.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
  }

  return result;
}
Exemple #20
0
/// getEVT - Return the value type corresponding to the specified type.  This
/// returns all pointers as MVT::iPTR.  If HandleUnknown is true, unknown types
/// are returned as Other, otherwise they are invalid.
EVT EVT::getEVT(Type *Ty, bool HandleUnknown){
  switch (Ty->getTypeID()) {
  default:
    return MVT::getVT(Ty, HandleUnknown);
  case Type::IntegerTyID:
    return getIntegerVT(Ty->getContext(), cast<IntegerType>(Ty)->getBitWidth());
  case Type::VectorTyID: {
    VectorType *VTy = cast<VectorType>(Ty);
    return getVectorVT(Ty->getContext(), getEVT(VTy->getElementType(), false),
                       VTy->getNumElements());
  }
  }
}
Exemple #21
0
VPFactory::VectorType
	VPFactory::getFlowKeys() const
{
	VectorType	retVector;

	for ( FlowDBConstIter it = flowDB.begin();
		  it != flowDB.end();
		  it ++ )
	{
		retVector.push_back( it->flowName );
	}

	return retVector;
}
Exemple #22
0
void BallTree<_Scalar>::buildNode(Node& node, std::vector<int>& indices, AxisAlignedBoxType aabb, int level)
{
	Scalar avgradius = 0.;
	for (std::vector<int>::const_iterator it=indices.begin(), end=indices.end() ; it!=end ; ++it)
			avgradius += mRadii[*it];
	avgradius = mRadiusScale * avgradius / Scalar(indices.size());
	VectorType diag = aabb.max - aabb.min;
	if  (int(indices.size())<mTargetCellSize
		|| avgradius*0.9 > std::max(std::max(diag.X(), diag.Y()), diag.Z())
		|| int(level)>=mMaxTreeDepth)
	{
		node.leaf = true;
		node.size = indices.size();
		node.indices = new unsigned int[node.size];
		for (unsigned int i=0 ; i<node.size ; ++i)
			node.indices[i] = indices[i];
		return;
	}
	unsigned int dim = vcg::MaxCoeffId(diag);
	node.dim = dim;
	node.splitValue = Scalar(0.5*(aabb.max[dim] + aabb.min[dim]));
  node.leaf = 0;

	AxisAlignedBoxType aabbLeft=aabb, aabbRight=aabb;
	aabbLeft.max[dim] = node.splitValue;
	aabbRight.min[dim] = node.splitValue;

	std::vector<int> iLeft, iRight;
	split(indices, aabbLeft, aabbRight, iLeft,iRight);

	// we don't need the index list anymore
	indices.clear();

	{
		// left child
		//mNodes.resize(mNodes.size()+1);
		Node* pChild = new Node();
		node.children[0] = pChild;
		buildNode(*pChild, iLeft, aabbLeft, level+1);
	}

	{
		// right child
		//mNodes.resize(mNodes.size()+1);
		Node* pChild = new Node();
		node.children[1] = pChild;
		buildNode(*pChild, iRight, aabbRight, level+1);
	}
}
Exemple #23
0
  void copy(const VectorType & cpu_vector,
            vector_slice<vector<SCALARTYPE> > & gpu_vector_slice )
  {
    if (cpu_vector.size() > 0)
    {
      std::vector<SCALARTYPE> temp_buffer(gpu_vector_slice.stride() * gpu_vector_slice.size());

      viennacl::backend::memory_read(gpu_vector_slice.handle(), sizeof(SCALARTYPE)*gpu_vector_slice.start(), sizeof(SCALARTYPE)*temp_buffer.size(), &(temp_buffer[0]));

      for (vcl_size_t i=0; i<cpu_vector.size(); ++i)
        temp_buffer[i * gpu_vector_slice.stride()] = cpu_vector[i];

      viennacl::backend::memory_write(gpu_vector_slice.handle(), sizeof(SCALARTYPE)*gpu_vector_slice.start(), sizeof(SCALARTYPE)*temp_buffer.size(), &(temp_buffer[0]));
    }
  }
Exemple #24
0
Tracer::FrameType
Tracer::GetLocalFrame(const PointType& pt) const
{
  VectorType gradient;
  this->DerivativeAt(pt, gradient);
  gradient.Normalize();
  gradient *= stepSize;

  // compute the tangent
  VectorType tangent;
  tangent[0] = - gradient[1];
  tangent[1] =   gradient[0];

  return std::make_pair(tangent, gradient);
}
static bool isByteSwap64(ShuffleVectorInst &SI, SmallVector<int, 16>&RefMasks)
{

    RefMasks.clear();
    unsigned VWidth = cast<VectorType>(SI.getType())->getNumElements();
    VectorType *LHS = cast<VectorType>(SI.getOperand(0)->getType());
    VectorType *RHS = cast<VectorType>(SI.getOperand(1)->getType());

    IntegerType *IT = dyn_cast<IntegerType>(LHS->getElementType());
    //When Element Type is not IntegerType or the Result's element number
    //can't be divided by 8, return false
    //TODO:Need to check all masks are all constants.
    if (IT == nullptr
        || ! IT->isIntegerTy(8)
        || VWidth % 8 != 0) {
        return false;
    }

    SmallVector<int, 16> Masks(SI.getShuffleMask());
    bool isByteSwap = true;

    for (unsigned i = 0; i < VWidth / 8; ++i) {
        unsigned base = Masks[i * 8];
        if (base % 8 != 7) {
            isByteSwap = false;
            break;
        }

        for (unsigned j = 1; j < 8; ++j) {
            if (base - Masks[i * 8 + j] != j) {
                isByteSwap = false;
                break;
            }
        }

        if (isByteSwap) {
            RefMasks.push_back(base / 8);
        } else {
            break;
        }
    }

    if (!isByteSwap) {
        RefMasks.clear();
    }

    return isByteSwap;
}
Exemple #26
0
/// \brief Given a vector and an element number, see if the scalar value is
/// already around as a register, for example if it were inserted then extracted
/// from the vector.
llvm::Value *llvm::findScalarElement(llvm::Value *V, unsigned EltNo) {
  assert(V->getType()->isVectorTy() && "Not looking at a vector?");
  VectorType *VTy = cast<VectorType>(V->getType());
  unsigned Width = VTy->getNumElements();
  if (EltNo >= Width)  // Out of range access.
    return UndefValue::get(VTy->getElementType());

  if (Constant *C = dyn_cast<Constant>(V))
    return C->getAggregateElement(EltNo);

  if (InsertElementInst *III = dyn_cast<InsertElementInst>(V)) {
    // If this is an insert to a variable element, we don't know what it is.
    if (!isa<ConstantInt>(III->getOperand(2)))
      return nullptr;
    unsigned IIElt = cast<ConstantInt>(III->getOperand(2))->getZExtValue();

    // If this is an insert to the element we are looking for, return the
    // inserted value.
    if (EltNo == IIElt)
      return III->getOperand(1);

    // Otherwise, the insertelement doesn't modify the value, recurse on its
    // vector input.
    return findScalarElement(III->getOperand(0), EltNo);
  }

  if (ShuffleVectorInst *SVI = dyn_cast<ShuffleVectorInst>(V)) {
    unsigned LHSWidth = SVI->getOperand(0)->getType()->getVectorNumElements();
    int InEl = SVI->getMaskValue(EltNo);
    if (InEl < 0)
      return UndefValue::get(VTy->getElementType());
    if (InEl < (int)LHSWidth)
      return findScalarElement(SVI->getOperand(0), InEl);
    return findScalarElement(SVI->getOperand(1), InEl - LHSWidth);
  }

  // Extract a value from a vector add operation with a constant zero.
  Value *Val = nullptr; Constant *Con = nullptr;
  if (match(V,
            llvm::PatternMatch::m_Add(llvm::PatternMatch::m_Value(Val),
                                      llvm::PatternMatch::m_Constant(Con)))) {
    if (Con->getAggregateElement(EltNo)->isNullValue())
      return findScalarElement(Val, EltNo);
  }

  // Otherwise, we don't know.
  return nullptr;
}
Exemple #27
0
template<typename VectorType> void ref_vector(const VectorType& m)
{
  typedef typename VectorType::Index Index;
  typedef typename VectorType::Scalar Scalar;
  typedef typename VectorType::RealScalar RealScalar;
  typedef Matrix<Scalar,Dynamic,1,VectorType::Options> DynMatrixType;
  typedef Matrix<Scalar,Dynamic,Dynamic,ColMajor> MatrixType;
  typedef Matrix<RealScalar,Dynamic,1,VectorType::Options> RealDynMatrixType;
  
  typedef Ref<VectorType> RefMat;
  typedef Ref<DynMatrixType> RefDynMat;
  typedef Ref<const DynMatrixType> ConstRefDynMat;
  typedef Ref<RealDynMatrixType , 0, InnerStride<> > RefRealMatWithStride;
  typedef Ref<DynMatrixType , 0, InnerStride<> > RefMatWithStride;

  Index size = m.size();
  
  VectorType  v1 = VectorType::Random(size),
              v2 = v1;
  MatrixType mat1 = MatrixType::Random(size,size),
             mat2 = mat1,
             mat3 = MatrixType::Random(size,size);
  
  Index i = internal::random<Index>(0,size-1);
  Index bsize = internal::random<Index>(1,size-i);
  
  RefMat rm0 = v1;
  VERIFY_IS_EQUAL(rm0, v1);
  RefDynMat rv1 = v1;
  VERIFY_IS_EQUAL(rv1, v1);
  RefDynMat rv2 = v1.segment(i,bsize);
  VERIFY_IS_EQUAL(rv2, v1.segment(i,bsize));
  rv2.setOnes();
  v2.segment(i,bsize).setOnes();
  VERIFY_IS_EQUAL(v1, v2);
  
  v2.segment(i,bsize).setRandom();
  rv2 = v2.segment(i,bsize);
  VERIFY_IS_EQUAL(v1, v2);
  
  ConstRefDynMat rm3 = v1.segment(i,bsize);
  v1.segment(i,bsize) *= 2;
  v2.segment(i,bsize) *= 2;
  VERIFY_IS_EQUAL(rm3, v2.segment(i,bsize));
  
  RefRealMatWithStride rm4 = v1.real();
  VERIFY_IS_EQUAL(rm4, v2.real());
  rm4.array() += 1;
  v2.real().array() += 1;
  VERIFY_IS_EQUAL(v1, v2);
  
  RefMatWithStride rm5 = mat1.row(i).transpose();
  VERIFY_IS_EQUAL(rm5, mat1.row(i).transpose());
  rm5.array() += 1;
  mat2.row(i).array() += 1;
  VERIFY_IS_EQUAL(mat1, mat2);
  rm5.noalias() = rm4.transpose() * mat3;
  mat2.row(i) = v2.real().transpose() * mat3;
  VERIFY_IS_APPROX(mat1, mat2);
}
Exemple #28
0
	Plane(ATy_ A, BTy_ B, CTy_ C, DTy_ D) : normal(A, B, C)
	{
		ValueType nlen = static_cast<ValueType>(1) / static_cast<ValueType>(normal.length());
		distanceConstant = -D * nlen;
		// renormalize normal
		normal = normal * nlen;
	}
template<typename VectorType> void map_class_vector(const VectorType& m)
{
  typedef typename VectorType::Index Index;
  typedef typename VectorType::Scalar Scalar;

  Index size = m.size();

  Scalar* array1 = internal::aligned_new<Scalar>(size);
  Scalar* array2 = internal::aligned_new<Scalar>(size);
  Scalar* array3 = new Scalar[size+1];
  Scalar* array3unaligned = (internal::UIntPtr(array3)%EIGEN_MAX_ALIGN_BYTES) == 0 ? array3+1 : array3;
  Scalar  array4[EIGEN_TESTMAP_MAX_SIZE];

  Map<VectorType, AlignedMax>(array1, size) = VectorType::Random(size);
  Map<VectorType, AlignedMax>(array2, size) = Map<VectorType,AlignedMax>(array1, size);
  Map<VectorType>(array3unaligned, size) = Map<VectorType>(array1, size);
  Map<VectorType>(array4, size)          = Map<VectorType,AlignedMax>(array1, size);
  VectorType ma1 = Map<VectorType, AlignedMax>(array1, size);
  VectorType ma2 = Map<VectorType, AlignedMax>(array2, size);
  VectorType ma3 = Map<VectorType>(array3unaligned, size);
  VectorType ma4 = Map<VectorType>(array4, size);
  VERIFY_IS_EQUAL(ma1, ma2);
  VERIFY_IS_EQUAL(ma1, ma3);
  VERIFY_IS_EQUAL(ma1, ma4);
  #ifdef EIGEN_VECTORIZE
  if(internal::packet_traits<Scalar>::Vectorizable && size>=AlignedMax)
    VERIFY_RAISES_ASSERT((Map<VectorType,AlignedMax>(array3unaligned, size)))
  #endif

  internal::aligned_delete(array1, size);
  internal::aligned_delete(array2, size);
  delete[] array3;
}
template<typename VectorType> void map_static_methods(const VectorType& m)
{
  typedef typename VectorType::Index Index;
  typedef typename VectorType::Scalar Scalar;

  Index size = m.size();

  Scalar* array1 = internal::aligned_new<Scalar>(size);
  Scalar* array2 = internal::aligned_new<Scalar>(size);
  Scalar* array3 = new Scalar[size+1];
  Scalar* array3unaligned = internal::UIntPtr(array3)%EIGEN_MAX_ALIGN_BYTES == 0 ? array3+1 : array3;

  VectorType::MapAligned(array1, size) = VectorType::Random(size);
  VectorType::Map(array2, size) = VectorType::Map(array1, size);
  VectorType::Map(array3unaligned, size) = VectorType::Map(array1, size);
  VectorType ma1 = VectorType::Map(array1, size);
  VectorType ma2 = VectorType::MapAligned(array2, size);
  VectorType ma3 = VectorType::Map(array3unaligned, size);
  VERIFY_IS_EQUAL(ma1, ma2);
  VERIFY_IS_EQUAL(ma1, ma3);

  internal::aligned_delete(array1, size);
  internal::aligned_delete(array2, size);
  delete[] array3;
}