Example #1
0
/// @bug template<typename Type> //IT DOES NOT WORK WITH A TEMPLATED FUNCTION; AND IT SHOULD!
void add(Array<Type , 2>& result, const Array<Type , 2>& a, const Array<Type , 2>& b)
{
  const int nrows = result.rows();
  const int ncols = result.cols();
  
#ifdef SLOW
  
  for(int i = 0; i < nrows; i++) {
    for(int j = 0; j < ncols; j++) {
      result(i, j) += a(i, j)  + b(i, j);
    }
  }
  
#else

  const Type * const ap = a.data();
  const Type * const bp = b.data();
  Type * const rp = result.data();
  const int s = result.stride(firstDim);
  
  //LOG('(' << rp << " , " << s << " , " << ap[0] << ')');
  
  for(int i = 0; i < nrows; i++) {
    for(int j = 0; j < ncols; j++) {
      rp[i * s + j] += ap[i * s + j] + bp[i * s + j];
    }
  }
  
#endif
  
}
Example #2
0
void MatrixVectorMultiply(const Array<double, 2> &A, const Array<double, 1> &v, Array<double, 1> &w)
{
	//In lapack world, A := A', however, if we use 'T' to transpose A, all goes back to normal
	int M = A.extent(0);
	int N = A.extent(1);
	int lda = A.stride(0);

	int vStride = v.stride(0);
	int wStride = w.stride(0);

	double alpha = 1;
	double beta = 0;

	BLAS_NAME(dgemv)(
		'T',		 			// Transpose A
		M,					// Rows of A 
		N, 					// Cols of A
		alpha, 					// Scale of A*v
		(double*)A.data(), 				// Pointer to A
		lda, 					// Size of first dim of A
		(double*)v.data(),				// Pointer to input vector 
		vStride, 				// Stride of input vector
		beta,	 				// Scale of w
		(double*)w.data(), 				// Pointer to output vector
		wStride					// Stride of output vector
	);		
}
Example #3
0
//Performs the matrix-vector product w = A v
void MatrixVectorMultiply(const Array<cplx, 2> &A, const Array<cplx, 1> &v, Array<cplx, 1> &w)
{
	//In lapack world, A := A', however, if we use 'T' to transpose A, all goes back to normal
	int M = A.extent(0);
	int N = A.extent(1);
	int lda = A.stride(0);

	int vStride = v.stride(0); 
	int wStride = w.stride(0); 

	acml::doublecomplex alpha, beta;
	alpha.real = 1;
	alpha.imag = 0;
	beta.real = 0;
	beta.imag = 0;

	BLAS_NAME(zgemv)(
		'T',					// Transpose A
		M,					// Rows of A 
		N, 					// Cols of A
		&alpha, 				// Scale of A*v
		(acml::doublecomplex*)A.data(), 				// Pointer to A
		lda, 					// Size of first dim of A
		(acml::doublecomplex*)v.data(),				// Pointer to input vector 
		vStride, 				// Stride of input vector
		&beta,	 				// Scale of w
		(acml::doublecomplex*)w.data(), 				// Pointer to output vector
		wStride					// Stride of output vector
	);
}
Example #4
0
void AddDoubleAngularProjectionCoplanar(Array<cplx, 4> angularData, Array<cplx, 2> sphericalHarmonics1,
		Array<cplx, 2> sphericalHarmonics2, Array<cplx, 2> radialProj, CoupledSpherical::CoupledIndex coupledIndex)
{
	CoupledSpherical::ClebschGordan cg;

	int l1 = coupledIndex.l1;
	int l2 = coupledIndex.l2;
	int L = coupledIndex.L;
	int M = coupledIndex.M;
	
	//intuitively obvious:
	int mMin = std::max(-l1, M-l2);
	int mMax = std::min(l1, M+l2);
//	for (int m=mMin; m<=mMax; m++)
//	{
//		//create a view to the current spherical harmonic and radialProjection arrays
//		Array<cplx, 1> sph1 = sphericalHarmonics1( MapLmIndex(l1, m), Range::all());
//		Array<cplx, 1> sph2 = sphericalHarmonics2( MapLmIndex(l2, M-m), Range::all());
//		double curCg = cg(l1, l2, m, M-m, L, M);
//
//		//Add data
//		angularData +=    curCg * sph1(tensor::i) * sph2(tensor::j)
//						* radialProj(tensor::k, tensor::l);
//	}

	int adExtent2 = angularData.extent(2);
	int adExtent3 = angularData.extent(3);

	for (int m=mMin; m<=mMax; m++)
	{
		//create a view to the current spherical harmonic and radialProjection arrays
		Array<cplx, 1> sph1 = sphericalHarmonics1( MapLmIndex(l1, m), Range::all());
		Array<cplx, 1> sph2 = sphericalHarmonics2( MapLmIndex(l2, M-m), Range::all());
		double curCg = cg(l1, l2, m, M-m, L, M);

		for (int i=0; i<angularData.extent(0); i++)
		{
			for (int j=0; j<angularData.extent(1); j++)
			{
				cplx A = curCg * sph1(i) * sph2(j);

				Array<cplx, 2> angData = angularData(i, j, Range::all(), Range::all());
				FORTRAN_NAME(sumangularprojection)(angData.data(), radialProj.data(), &A, &adExtent2, &adExtent3);

			//	for (int k=0; k<angularData.extent(2); k++)
			//	{
			//		//Add data
			//		angularData(i,j,k,Range::all()) +=  A * radialProj(k, Range::all());
			//	}
			}
		}
	}
}
Example #5
0
File: lj.cpp Project: js850/PyGMIN
double LJ::get_energy_gradient(Array &x, Array &grad)
{
	int natoms = x.size()/3;
	double e;
	int periodic = 0;
	double boxl = -1;

	ljenergy_gradient_(x.data(), &natoms, &e, grad.data(),
			&_eps, &_sigma, &periodic, &boxl);

	return e;
}
Cryptography* EllipticCurveCryptographyFactory::createCryptography(const PublicKey& theirKey) const {
	CryptoPP::DL_GroupParameters_EC<CryptoPP::ECP> groupParameters(curveId);
	CryptoPP::ECDH<CryptoPP::ECP>::Domain ecdh(groupParameters);

	Array<byte>* secret = new Array<byte>(ecdh.AgreedValueLength());
	ecdh.Agree(secret->data(), myKeys->privateKey->const_data(), theirKey.const_data(), false);
	// Log key
	Logger(debug) << "Shared secret: " << Utilities::hex_str(*secret) << std::endl;

	Array<byte>* choppedSecret = new Array<byte>(secret->data(), CryptoPP::AES::MAX_KEYLENGTH);
	Cryptography* crypt = crypto->createCryptography(*choppedSecret);
	return crypt;
}
Example #7
0
void inplace_partial_permute(UntypedArray& x, RawArray<const int> perm, Array<char>& work, const int block) {
  const int m = perm.size();
  const int b_size = block*x.t_size();
  GEODE_ASSERT(x.size()==block*m);
  const int space = m ? (perm.max()+1)*b_size : 0;
  work.resize(space);
  for (int i=0;i<m;i++) {
    const int pi = perm[i];
    if (pi >= 0)
      memcpy(work.data()+pi*b_size,x.data()+i*b_size,b_size);
  }
  x.resize(space/x.t_size());
  memcpy(x.data(),work.data(),space);
}
		bool getBuffer(const uint32 vertexSize, const uint32 indexSize, Vertex2D** pVertex, IndexType** pIndices, IndexType* indexOffset, D3D11Render2DCommandManager& commandManager)
		{
			// VB
			const uint32 requiredVertexSize = m_vertexArrayWritePos + vertexSize;

			if (m_vertices.size() < requiredVertexSize)
			{
				if (MaxVertexSize < requiredVertexSize)
				{
					return false;
				}

				resizeVertices(requiredVertexSize);
			}

			// IB
			const uint32 requiredIndexSize = m_indexArrayWritePos + indexSize;

			if (m_indices.size() < requiredIndexSize)
			{
				if (MaxIndexSize < requiredIndexSize)
				{
					return false;
				}

				resizeIndices(requiredIndexSize);
			}

			if (VertexBufferSize < (m_batches.back().vertexPos + vertexSize)
				|| IndexBufferSize < (m_batches.back().indexPos + indexSize))
			{
				m_batches.emplace_back();

				commandManager.pushNextBatch();
			}

			*pVertex = m_vertices.data() + m_vertexArrayWritePos;
			*pIndices = m_indices.data() + m_indexArrayWritePos;
			*indexOffset = m_batches.back().vertexPos;

			m_vertexArrayWritePos += vertexSize;
			m_indexArrayWritePos += indexSize;

			m_batches.back().vertexPos += vertexSize;
			m_batches.back().indexPos += indexSize;
		
			return true;
		}
Example #9
0
 int run(Array &x)
 {
     double fx;
     int ret = lbfgs(x.size(), x.data(), &fx, _evaluate, _progress, this, &_params);
     _error_code = ret;
     return ret;
 }
Example #10
0
//-----------------------------------------------------------------------------
void Function::eval(Array<double>& values, const Array<double>& x) const
{
  dolfin_assert(_function_space);
  dolfin_assert(_function_space->mesh());
  const Mesh& mesh = *_function_space->mesh();

  // Find the cell that contains x
  const double* _x = x.data();
  const Point point(mesh.geometry().dim(), _x);

  // Get index of first cell containing point
  unsigned int id
    = mesh.bounding_box_tree()->compute_first_entity_collision(point);

  // If not found, use the closest cell
  if (id == std::numeric_limits<unsigned int>::max())
  {
    if (_allow_extrapolation)
      id = mesh.bounding_box_tree()->compute_closest_entity(point).first;
    else
    {
      dolfin_error("Function.cpp",
                   "evaluate function at point",
                   "The point is not inside the domain. Consider calling \"Function::set_allow_extrapolation(true)\" on this Function to allow extrapolation");
    }
  }

  // Create cell that contains point
  const Cell cell(mesh, id);
  ufc::cell ufc_cell;
  cell.get_cell_data(ufc_cell);

  // Call evaluate function
  eval(values, x, cell, ufc_cell);
}
Example #11
0
static void testOrigBinary(cxuint testCase, const char* origBinaryFilename)
{
    Array<cxbyte> inputData;
    Array<cxbyte> output;
    std::string origBinFilenameStr(origBinaryFilename);
    filesystemPath(origBinFilenameStr); // convert to system path (native separators)
    
    inputData = loadDataFromFile(origBinFilenameStr.c_str());
    ROCmBinary rocmBin(inputData.size(), inputData.data(), 0);
    
    ROCmInput rocmInput = genROCmInput(rocmBin);
    ROCmBinGenerator binGen(&rocmInput);
    binGen.generate(output);
    
    if (output.size() != inputData.size())
    {
        std::ostringstream oss;
            oss << "Failed for #" << testCase << " file=" << origBinaryFilename <<
                    ": expectedSize=" << inputData.size() <<
                    ", resultSize=" << output.size();
        throw Exception(oss.str());
    }
    for (size_t i = 0; i < inputData.size(); i++)
        if (output[i] != inputData[i])
        {
            std::ostringstream oss;
            oss << "Failed for #" << testCase << " file=" << origBinaryFilename <<
                    ": byte=" << i;
            throw Exception(oss.str());
        }
}
Example #12
0
static void testOrigBinary(cxuint testCase, const char* origBinaryFilename)
{
    Array<cxbyte> inputData;
    std::unique_ptr<GalliumBinary> galliumBin;
    Array<cxbyte> output;
    std::string origBinFilenameStr(origBinaryFilename);
    filesystemPath(origBinFilenameStr); // convert to system path (native separators)
    
    inputData = loadDataFromFile(origBinFilenameStr.c_str());
    galliumBin.reset(new GalliumBinary(inputData.size(), inputData.data(),
            GALLIUM_INNER_CREATE_SECTIONMAP |
            GALLIUM_INNER_CREATE_SYMBOLMAP | GALLIUM_INNER_CREATE_PROGINFOMAP));
    
    GalliumInput galliumInput = getGalliumInput(true, galliumBin.get());
    GalliumBinGenerator binGen(&galliumInput);
    binGen.generate(output);
    
    if (output.size() != inputData.size())
    {
        std::ostringstream oss;
            oss << "Failed for #" << testCase << " file=" << origBinaryFilename <<
                    ": expectedSize=" << inputData.size() <<
                    ", resultSize=" << output.size();
        throw Exception(oss.str());
    }
    for (size_t i = 0; i < inputData.size(); i++)
        if (output[i] != inputData[i])
        {
            std::ostringstream oss;
            oss << "Failed for #" << testCase << " file=" << origBinaryFilename <<
                    ": byte=" << i;
            throw Exception(oss.str());
        }
}
Example #13
0
 static std::string print(const Array<T,Coord>& val) {
     std::stringstream str;
     str << type_printer<Array<T,Coord>>::print()
         << "(size="     << val.size()
         << ", pointer=" << val.data() << ")";
     return str.str();
 }
Example #14
0
/**
* Converts an Octave Array into an R matrix or vector.
*/
template <int RTYPE, typename T> SEXP wrapArray(const Array<T>& x){

	// compute dimensions
	int n = x.rows();
	int p = x.cols();
	int L = n*p;

	VERBOSE_LOG("[%i x %i]", n, p);

	// convert matrix
	Rcpp::Matrix<RTYPE> res(n,p);
	const T* o_val = x.data() + L-1;
	for(int idx = L-1; idx>=0; --idx, --o_val)
		res[idx] = *o_val;

	// if only one row: return it as a vector
	if( n == 1 ){
		VERBOSE_LOG(" -> Vector[%i]\n", p);
		return Rcpp::Vector<RTYPE>(res.row(0));
	}
	VERBOSE_LOG("\n");

	return res;

}
Example #15
0
//opérateur égal
void Array::operator=(const Array array2){
  delete[] data_;
  size_=array2.size();
  data_ = new double[size_];
  for (int i=0; i<array2.size();i++){
    data_[i]=array2.data()[i];
  }
}
Example #16
0
//Constructeur par copie
Array::Array(const Array& array) {
  size_  = array.size();
  data_ = new double[size_];
  
  for (int i=0; i<size_;i++){
    data_[i]=array.data()[i];
  }
}
Example #17
0
// Absorb a compressed output block
static void absorb_compressed_output(accumulating_block_store_t* output_blocks, const local_id_t local_block_id, const uint8_t dimension, Array<const uint8_t> compressed, Array<Vector<super_t,2>> buffer) {
  // Uncompress block into temporary buffer, then copy back to buffer so that accumulate can use the temporary.
  const auto local_buffer = local_fast_uncompress(compressed,output_blocks->local_block_line_event(local_block_id,dimension));
  memcpy(buffer.data(),local_buffer.data(),memory_usage(local_buffer));
  const auto block_data = buffer.slice(0,local_buffer.size());
  // Send to block store
  output_blocks->accumulate(local_block_id,dimension,block_data);
}
Example #18
0
 ArrayStore(Array<T, Rank> &a) :
 ptr_(a.data()),
 owner_(a),
 shape_(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
 rank_(a.rank()) {
     for (int i = 0; i < Rank; ++i)
         shape_(i) = a.extent(i);
 }
Example #19
0
	Process Process::popen(StringRef exe, ArrayRef<StringRef> arguments) {
		Process p;

		int in[2];
		int out[2];
		int err[2];
		int pid;

		pipe(in);
		pipe(out);
		pipe(err);

		pid = fork();
		if (pid > 0) {
			// parent: set up pipes
			::close(in[0]);
			::close(out[1]);
			::close(err[1]);
			p.impl->pid = pid;
			p.impl->stdin_raw = OutputPipeStream(in[1]);
			p.impl->stdout = InputPipeStream(out[0]);
			p.impl->stderr = InputPipeStream(err[0]);
			p.impl->status = Status::Running;
		} else if (pid == 0) {
			// transform arguments into a format that execvp can understand
			COPY_STRING_REF_TO_CSTR_BUFFER(exe_cstr, exe);
			Array<String> args;
			Array<const char*> argv;
			args.reserve(arguments.size()+1);
			argv.reserve(arguments.size()+2);
			argv.push_back(exe_cstr.data());
			for (auto& arg: arguments) {
				args.emplace_back(String(arg) + '\0');
				argv.emplace_back(args.back().data());
			}
			argv.push_back(nullptr);

			// child: replace stdin/stdout/stderr
			::close(in[1]);
			::close(out[0]);
			::close(err[0]);

			::close(0);
			dup(in[0]);
			::close(1);
			dup(out[1]);
			::close(2);
			dup(err[1]);

			::execvp(exe_cstr.data(), (char* const*)argv.data());
			::perror("execvp");
			exit(1);
		} else {
			raise<PipeError>("fork: {0}", ::strerror(errno));
		}

		return std::move(p);
	}
Example #20
0
unsigned FileInfo::find_attribute(const Array<u8>& ntfs_file_rec_buf, u32 type, u16 instance) {
  const MFT_RECORD* mft_rec = reinterpret_cast<const MFT_RECORD*>(ntfs_file_rec_buf.data());

  unsigned attr_off = mft_rec->attrs_offset;
  while (true) {
    const ATTR_HEADER* attr_header = reinterpret_cast<const ATTR_HEADER*>(ntfs_file_rec_buf.data() + attr_off);
    CHECK_FMT(attr_off + sizeof(attr_header->type) <= ntfs_file_rec_buf.size());
    if (attr_header->type == AT_END) return -1; // not found
    CHECK_FMT(attr_off + sizeof(ATTR_HEADER) <= ntfs_file_rec_buf.size());

    if (type == attr_header->type) {
      if ((instance == 0) || (instance == attr_header->instance)) return attr_off; // found
    }

    CHECK_FMT(attr_header->length != 0); // prevent infinite loop
    attr_off += attr_header->length;
  }
}
Example #21
0
Probe::Probe(const Array<double>& x, const FunctionSpace& V) :
  _element(V.element()), _num_evals(0)
{

  const Mesh& mesh = *V.mesh();
  std::size_t gdim = mesh.geometry().dim();
    
  // Find the cell that contains probe
  const Point point(gdim, x.data());
  unsigned int cell_id = mesh.bounding_box_tree()->compute_first_entity_collision(point);

  // If the cell is on this process, then create an instance 
  // of the Probe class. Otherwise raise a dolfin_error.
  if (cell_id != std::numeric_limits<unsigned int>::max())
  {
    // Store position of probe
    for (std::size_t i = 0; i < 3; i++) 
      _x[i] = (i < gdim ? x[i] : 0.0);
    
    // Compute in tensor (one for scalar function, . . .)
    _value_size_loc = 1;
    for (std::size_t i = 0; i < _element->value_rank(); i++)
       _value_size_loc *= _element->value_dimension(i);

    _probes.resize(_value_size_loc);

    // Create cell that contains point
    dolfin_cell.reset(new Cell(mesh, cell_id));
    dolfin_cell->get_cell_data(ufc_cell);
    
    coefficients.resize(_element->space_dimension());
    
    // Cell vertices
    dolfin_cell->get_vertex_coordinates(vertex_coordinates);
        
    // Create work vector for basis
    basis_matrix.resize(_value_size_loc);
    for (std::size_t i = 0; i < _value_size_loc; ++i)
      basis_matrix[i].resize(_element->space_dimension());
        
    std::vector<double> basis(_value_size_loc);
    const int cell_orientation = 0;
    for (std::size_t i = 0; i < _element->space_dimension(); ++i)
    {
      _element->evaluate_basis(i, &basis[0], &x[0], 
                               vertex_coordinates.data(), 
                               cell_orientation);
      for (std::size_t j = 0; j < _value_size_loc; ++j)
        basis_matrix[j][i] = basis[j];
    }
  }  
  else
  {  
    dolfin_error("Probe.cpp","set probe","Probe is not found on processor");
  }
}
Example #22
0
        //----------------------------
        // Differentiation Methods
        //----------------------------
        void StdExpansion2D::PhysTensorDeriv(const Array<OneD, const NekDouble>& inarray,
                         Array<OneD, NekDouble> &outarray_d0,
                         Array<OneD, NekDouble> &outarray_d1)
        {
            int nquad0 = m_base[0]->GetNumPoints();
            int nquad1 = m_base[1]->GetNumPoints();

            if (outarray_d0.num_elements() > 0) // calculate du/dx_0
            {
                DNekMatSharedPtr D0 = m_base[0]->GetD();
                if(inarray.data() == outarray_d0.data())
                {
                    Array<OneD, NekDouble> wsp(nquad0 * nquad1);
                    Vmath::Vcopy(nquad0 * nquad1,inarray.get(),1,wsp.get(),1);
                    Blas::Dgemm('N', 'N', nquad0, nquad1, nquad0, 1.0,
                                &(D0->GetPtr())[0], nquad0, &wsp[0], nquad0, 0.0,
                                &outarray_d0[0], nquad0);
                }
                else
                {
                    Blas::Dgemm('N', 'N', nquad0, nquad1, nquad0, 1.0,
                                &(D0->GetPtr())[0], nquad0, &inarray[0], nquad0, 0.0,
                                &outarray_d0[0], nquad0);
                }
            }

            if (outarray_d1.num_elements() > 0) // calculate du/dx_1
            {
                DNekMatSharedPtr D1 = m_base[1]->GetD();
                if(inarray.data() == outarray_d1.data())
                {
                    Array<OneD, NekDouble> wsp(nquad0 * nquad1);
                    Vmath::Vcopy(nquad0 * nquad1,inarray.get(),1,wsp.get(),1);
                    Blas:: Dgemm('N', 'T', nquad0, nquad1, nquad1, 1.0, &wsp[0], nquad0,
                                 &(D1->GetPtr())[0], nquad1, 0.0, &outarray_d1[0], nquad0);
                }
                else
                {
                    Blas:: Dgemm('N', 'T', nquad0, nquad1, nquad1, 1.0, &inarray[0], nquad0,
                                 &(D1->GetPtr())[0], nquad1, 0.0, &outarray_d1[0], nquad0);
                }
            }
        }
Example #23
0
/*!
    Routine to compute the coarse residual vector.

    @param[inout]  A - Sparse matrix object containing pointers to mgData->Axf,
                   the fine grid matrix-vector product and mgData->rc the coarse
                   residual vector.

    @param[in]    rf - Fine grid RHS.


    Note that the fine grid residual is never explicitly constructed.  We only
    compute it for the fine grid points that will be injected into corresponding
    coarse grid points.

    @return Returns zero on success and a non-zero value otherwise.
*/
inline int
ComputeRestrictionKernel(
    Array<floatType>   &Axf,
    Array<local_int_t> &Af2c,
    Array<floatType>   &rc,
    Array<floatType>   &rf
) {
    const floatType *const Axfv = Axf.data();
    const local_int_t *const f2c = Af2c.data();
    floatType *const rcv = rc.data();
    //
    const floatType *const rfv = rf.data();

    const local_int_t nc = rc.length();
    for (local_int_t i = 0; i < nc; ++i) {
        rcv[i] = rfv[f2c[i]] - Axfv[f2c[i]];
    }
    //
    return 0;
}
Example #24
0
 inline Vector_const(
     const Array<eT> &inArray)
     : mMemoryHandle(inArray.memoryHandle()),
       mVector(
         const_cast<eT*>(inArray.data()),
         inArray.size(),
         false /* copy_aux_mem */,
         true /* strict */),
       n_rows(mVector.n_rows),
       n_cols(mVector.n_cols),
       n_elem(mVector.n_elem)
     { }
void ThreadManager::joinAnyOrAll(const Array<Thread*>& ths, bool all)
{
	Array<HANDLE> threadHandles;
	for (int i = 0; i < ths.size(); i++)
	{
		if (ths[i]->isFinished())
			continue;
		threadHandles.append(ths[i]->getHandle());
	}
	DWORD result = WaitForMultipleObjects((DWORD)threadHandles.size(), threadHandles.data(), (BOOL)all, INFINITE);
	Assert(result == WAIT_OBJECT_0); (void)result;
}
Example #26
0
//Performs the matrix-matrix product C = A B
void MatrixMatrixMultiply(const Array<cplx, 2> &A, const Array<cplx, 2> &B, Array<cplx, 2> &C)
{
	/* We have c-style ordering, which corresponds to having all arrays transposed in 
	 * fortran-style ordering 
	 * and must therefore swich ordering and use transpose
	 * C := A B => C' := (B' A')
	*/

	//In blas world, C := C'
	int M = C.extent(1);
	int N = C.extent(0);
	int K = B.extent(0);

	int lda = A.stride(0);
	int ldb = B.stride(0);
	int ldc = C.stride(0);

	acml::doublecomplex alpha, beta;
	alpha.real = 1;
	alpha.imag = 0;
	beta.real = 0;
	beta.imag = 0;

	BLAS_NAME(zgemm)(
		'N',				// Transpose A
		'N',				// Transpose B
		M,				// Rows in C'
		N,				// Cols in C'
		K,				// Cols in A
		&alpha, 			// Scaling of A*B
		(acml::doublecomplex*)B.data(),	// Pointer to A
		ldb,				// Size of first dim of A
		(acml::doublecomplex*)A.data(),	// Pointer to B
		lda,				// Size of first dim of B
		&beta,				// Scaling of C
		(acml::doublecomplex*)C.data(),	// Pointer to C
		ldc				// Size of first dim of C
	);
}
Example #27
0
    void StdExpansion1D::PhysTensorDeriv(const Array<OneD, const NekDouble>& inarray,
                         Array<OneD, NekDouble>& outarray)
    {
        int nquad = GetTotPoints();
        DNekMatSharedPtr D = m_base[0]->GetD();

#ifdef NEKTAR_USING_DIRECT_BLAS_CALLS

        if( inarray.data() == outarray.data())
        {
            Array<OneD, NekDouble> wsp(nquad);
            CopyArray(inarray, wsp);
            Blas::Dgemv('N',nquad,nquad,1.0,&(D->GetPtr())[0],nquad,
                        &wsp[0],1,0.0,&outarray[0],1);
        }
        else
        {
            Blas::Dgemv('N',nquad,nquad,1.0,&(D->GetPtr())[0],nquad,
                        &inarray[0],1,0.0,&outarray[0],1);
        }

#else //NEKTAR_USING_DIRECT_BLAS_CALLS

        NekVector<NekDouble> out(nquad,outarray,eWrapper);

        if(inarray.data() == outarray.data()) // copy intput array
        {
            NekVector<NekDouble> in(nquad,inarray,eCopy);
            out = (*D)*in;
        }
        else
        {
            NekVector<NekDouble> in (nquad,inarray,eWrapper);
            out = (*D)*in;
        }

#endif //NEKTAR_USING_DIRECT_BLAS_CALLS
    }
Example #28
0
//opérateur somme
Array Array::operator+(const Array array2){
  
  Array newarray(size_+array2.size());
  
  for (int i=0; i<size_;i++){
    newarray[i]=data_[i];
  }
  
  for (int i=size_; i<(size_+array2.size());i++){
    newarray[i]=array2.data()[i-size_];
  }
  
  return newarray;
}
    Event CommandQueue::enqueueUnmap(const Buffer& buffer, void *mappedPtr,
                                     const Epic::Core::Array<Event>& eventWaitList) const
    {
        Event ret;
        cl_int err = 0;
        Array<cl_event> events = eventArrayToCLEventArray(eventWaitList);

        err = clEnqueueUnmapMemObject(queueHandle(), buffer.bufferHandle(), mappedPtr,
                                      events.count(), events.data(), ret.eventPointer());

        EPIC_OPENCL_CHECK_ERROR(err)

        return ret;
    }
Example #30
0
void ArrayTest::access() {
    Array a(7);
    for(std::size_t i = 0; i != 7; ++i)
        a[i] = i;

    CORRADE_COMPARE(a.data(), static_cast<int*>(a));
    CORRADE_COMPARE(*(a.begin()+2), 2);
    CORRADE_COMPARE(a[4], 4);
    CORRADE_COMPARE(a.end()-a.begin(), a.size());

    const auto b = Array::from(7, 3, 5, 4);
    CORRADE_COMPARE(b.data(), static_cast<const int*>(b));
    CORRADE_COMPARE(b[2], 5);
}