当前位置: 首页>>代码示例>>C++>>正文


C++ DataArray类代码示例

本文整理汇总了C++中DataArray的典型用法代码示例。如果您正苦于以下问题:C++ DataArray类的具体用法?C++ DataArray怎么用?C++ DataArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DataArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: data

void Feature::data(const DataArray &data) {
    util::checkEntityInput(data);
    if (!data.isValidEntity()) {
        throw UninitializedEntity();
    }
    backend()->data(data.id());
}
开发者ID:G-Node,项目名称:nix,代码行数:7,代码来源:Feature.cpp

示例2: Ptr

typename Wavefunction<Rank>::Ptr Wavefunction<Rank>::CopyDeep() const 
{
	/* Set up representations and stuff */
	Ptr newPsi = Ptr(new Wavefunction());
	newPsi->SetRepresentation(this->Repr->Copy());
	
	/* Allocate data */
	for (size_t i = 0; i < this->WavefunctionData.size(); i++)
	{
		//Allocate data buffer in new wavefunction
		DataArray oldData ( GetData(i) );
		int bufferName = newPsi->AllocateData(oldData.shape());
		if (bufferName != (int)i)
		{
			throw std::runtime_error("What! something is wrong in Wavefunction::CopyDeep()");
		}

		//Copy data buffer to new wavefunction
		DataArray newData ( newPsi->GetData(bufferName) );
		newData = oldData;
	}

	//Set active buffer on the new wavefunction
	newPsi->SetActiveBuffer(this->GetActiveBufferName());

	return newPsi;
}
开发者ID:AtomAleks,项目名称:PyProp,代码行数:27,代码来源:wavefunction.cpp

示例3: stringfromll

 void PerconaFTEngine::Stats(Context& ctx, std::string& str)
 {
     str.append("perconaft_version:").append(stringfromll(DB_VERSION_MAJOR)).append(".").append(stringfromll(DB_VERSION_MINOR)).append(".").append(
             stringfromll(DB_VERSION_PATCH)).append("\r\n");
     DataArray nss;
     ListNameSpaces(ctx, nss);
     PerconaFTLocalContext& local_ctx = g_local_ctx.GetValue();
     for (size_t i = 0; i < nss.size(); i++)
     {
         DB* db = GetFTDB(ctx, nss[i], false);
         if (NULL == db)
             continue;
         str.append("\r\nDB[").append(nss[i].AsString()).append("] Stats:\r\n");
         DB_BTREE_STAT64 st;
         memset(&st, 0, sizeof(st));
         db->stat64(db, local_ctx.transc.Peek(), &st);
         str.append("bt_nkeys:").append(stringfromll(st.bt_nkeys)).append("\r\n");
         str.append("bt_ndata:").append(stringfromll(st.bt_ndata)).append("\r\n");
         str.append("bt_fsize:").append(stringfromll(st.bt_fsize)).append("\r\n");
         str.append("bt_dsize:").append(stringfromll(st.bt_dsize)).append("\r\n");
         str.append("bt_create_time_sec:").append(stringfromll(st.bt_create_time_sec)).append("\r\n");
         str.append("bt_modify_time_sec:").append(stringfromll(st.bt_modify_time_sec)).append("\r\n");
         str.append("bt_verify_time_sec:").append(stringfromll(st.bt_verify_time_sec)).append("\r\n");
     }
 }
开发者ID:yinqiwen,项目名称:ardb,代码行数:25,代码来源:perconaft_engine.cpp

示例4: backend

bool Tag::hasReference(const DataArray &reference) const {
    if (!util::checkEntityInput(reference, false)) {
        return false;
    }
    DataArray da = backend()->getReference(reference.name());
    return da && da.id() == reference.id();
}
开发者ID:G-Node,项目名称:nix,代码行数:7,代码来源:Tag.cpp

示例5: retrieveFeatureData

DataView retrieveFeatureData(const Tag &tag, size_t feature_index) {
    if (tag.featureCount() == 0) {
        throw nix::OutOfBounds("There are no features associated with this tag!", 0);
    }
    if (feature_index > tag.featureCount()) {
        throw nix::OutOfBounds("Feature index out of bounds.", 0);
    }
    Feature feat = tag.getFeature(feature_index);
    DataArray data = feat.data();
    if (data == nix::none) {
        throw nix::UninitializedEntity();
        //return NDArray(nix::DataType::Float,{0});
    }
    if (feat.linkType() == nix::LinkType::Tagged) {
        NDSize offset, count;
        getOffsetAndCount(tag, data, offset, count);
        if (!positionAndExtentInData(data, offset, count)) {
            throw nix::OutOfBounds("Requested data slice out of the extent of the Feature!", 0);
        }
        DataView io = DataView(data, count, offset);
        return io;
    }
    // for untagged and indexed return the full data
    NDSize offset(data.dataExtent().size(), 0);
    DataView io = DataView(data, data.dataExtent(), offset);
    return io;
}
开发者ID:neurodebian,项目名称:nix,代码行数:27,代码来源:dataAccess.cpp

示例6: findHistogram

void findHistogram(IDataArray::Pointer inputData, int32_t* ensembleArray, int32_t* eIds, int NumberOfBins, bool removeBiasedFeatures, bool* biasedFeatures)
{
  DataArray<T>* featureArray = DataArray<T>::SafePointerDownCast(inputData.get());
  if (NULL == featureArray)
  {
    return;
  }

  T* fPtr = featureArray->getPointer(0);
  size_t numfeatures = featureArray->getNumberOfTuples();

  int32_t bin;
  int32_t ensemble;
  float min = 1000000.0f;
  float max = 0.0f;
  float value;
  for (size_t i = 1; i < numfeatures; i++)
  {
    value = fPtr[i];
    if(value > max) { max = value; }
    if(value < min) { min = value; }
  }
  float stepsize = (max - min) / NumberOfBins;

  for (size_t i = 1; i < numfeatures; i++)
  {
    if(removeBiasedFeatures == false || biasedFeatures[i] == false)
    {
      ensemble = eIds[i];
      bin = (fPtr[i] - min) / stepsize;
      if(bin >= NumberOfBins) { bin = NumberOfBins - 1; }
      ensembleArray[(NumberOfBins * ensemble) + bin]++;
    }
  }
}
开发者ID:BlueQuartzSoftware,项目名称:DREAM3D,代码行数:35,代码来源:FindFeatureHistogram.cpp

示例7: FlushAll

 int Engine::FlushAll(Context& ctx)
 {
     DataArray nss;
     ListNameSpaces(ctx, nss);
     for (size_t i = 0; i < nss.size(); i++)
     {
         Flush(ctx, nss[i]);
     }
     return 0;
 }
开发者ID:omegablitz,项目名称:ardb,代码行数:10,代码来源:engine.cpp

示例8: f

void SortTimeFunction::f() {
  const int n           = m_copy.size();
  const int elementSize = m_copy.getElementSize();
  DataArray data        = m_copy;
  switch(elementSize) {
  case 1 : m_sortMethod->getMethod()(data.getData(), n, elementSize, CountComparator<BYTE>(          m_compareCount)); break;
  case 2 : m_sortMethod->getMethod()(data.getData(), n, elementSize, CountComparator<unsigned short>(m_compareCount)); break;
  default: m_sortMethod->getMethod()(data.getData(), n, elementSize, CountComparator<unsigned int  >(m_compareCount)); break;
  }
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:10,代码来源:AnalyzeSortMethod.cpp

示例9: subtractVector3d

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void subtractVector3d(DataArray<double>::Pointer data, double* v)
{
  size_t count = data->getNumberOfTuples();
  for (size_t i = 0; i < count; ++i)
  {
    double* ptr = data->getPointer(i * 3);
    ptr[0] = ptr[0] - v[0];
    ptr[1] = ptr[1] - v[1];
    ptr[2] = ptr[2] - v[2];
  }
}
开发者ID:ricortiz,项目名称:DREAM3D,代码行数:14,代码来源:CalculateTriangleGroupCurvatures.cpp

示例10: CompactAll

 int Engine::CompactAll(Context& ctx)
 {
     DataArray nss;
     ListNameSpaces(ctx, nss);
     for (size_t i = 0; i < nss.size(); i++)
     {
         KeyObject start, end;
         start.SetNameSpace(nss[i]);
         Compact(ctx, start, end);
     }
     return 0;
 }
开发者ID:omegablitz,项目名称:ardb,代码行数:12,代码来源:engine.cpp

示例11: CreateArray

    /**
     * @brief Static constructor
     * @param numTuples The number of tuples in the array.
     * @param numComponents The number of Components in each Tuple
     * @param name The name of the array
     * @return Boost::Shared_Ptr wrapping an instance of DataArrayTemplate<T>
     */
    static Pointer CreateArray(size_t numTuples, int numComponents, const std::string &name)
    {

      DataArray<T>* d = new DataArray<T> (numTuples, numComponents, true);
      if (d->Allocate() < 0)
      { // Could not allocate enough memory, reset the pointer to null and return
        delete d;
        return DataArray<T>::NullPointer();
      }
      d->SetName(name);
      Pointer ptr(d);
      return ptr;
    }
开发者ID:tuks188,项目名称:DREAM3D,代码行数:20,代码来源:DataArray.hpp

示例12: createDataArray

    DataArray createDataArray(const std::string &name,
                              const std::string &type,
                              const T &data) {
         const Hydra<const T> hydra(data);
         DataType dtype = hydra.element_data_type();

         const NDSize shape = hydra.shape();
         DataArray da = createDataArray(name, type, dtype, shape);

         const NDSize offset(shape.size(), 0);
         da.setData(data, offset);

         return da;
    }
开发者ID:wvangeit,项目名称:nix,代码行数:14,代码来源:Block.hpp

示例13: combineImages

/**
 * packerに基づきイメージを結合する
 */
static void combineImages(){
	// 出力フォーマットの選別
	const int ch = getChannels(ofmt_type);
	const int type = (ch == 4)? CV_8UC4 : CV_8UC3;
	const cv::Scalar scalar = (ch == 4)? cv::Scalar(127, 127, 127, 255) : cv::Scalar(127, 127, 127);	// 初期色

	cv::Mat dst(cv::Size(packer.getW(), packer.getH()), type, scalar);

	int count = 0;	// for debug
	DataArray::iterator it = inputs.begin();
	for(; it != inputs.end(); it++){
		if(!it->fit)
			continue;	// skip

		cv::Mat src = cv::imread(it->path, -1);
		if(src.channels() != ch){
			adjustmentImage(src, ch);
		}
		cv::Mat roi = dst(cv::Rect(it->fit->rect.getX() + packer.getPadding(), it->fit->rect.getY() + packer.getPadding(), it->w, it->h));
		src.copyTo(roi);
		// for debug
#if 0
		cv::rectangle(dst, cv::Rect(it->fit->rect.getX(), it->fit->rect.getY(), it->fit->rect.getW(), it->fit->rect.getH()), cv::Scalar(255, 255, 255), 1);
		std::ostringstream oss;
		oss << it->w << "x" << it->h << "(" << count << ")";
		count++;
		const std::string size = oss.str();
		cv::putText(dst, size, cv::Point(it->fit->rect.getX() + 1, it->fit->rect.getY() + 21), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 0), 1);
		cv::putText(dst, size, cv::Point(it->fit->rect.getX(), it->fit->rect.getY() + 20), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(255, 255, 255), 1);
#endif
	}
	// 出力
	if((om_type == OutputMode_WriteOnly) || (om_type == OutputMode_Both)){
		bool ret = cv::imwrite(output_path, dst, params);
	}
	if((om_type == OutputMode_DisplayOnly) || (om_type == OutputMode_Both)){
		std::ostringstream oss;
		oss << "packed image(" << packer.getW() << " x " << packer.getH() << ")";
		const std::string name = oss.str();
		cv::namedWindow(name, CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO);
		cv::imshow(name, dst);
		if(ch == 4){
			std::vector<cv::Mat> mv;
			cv::split(dst, mv);
			cv::Mat dsta = mv[3].clone();
			cv::imshow("packed image(alpha)", dsta);
		}
	}
}
开发者ID:Hasenpfote,项目名称:2dpacker,代码行数:52,代码来源:main.cpp

示例14: if

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
std::vector<int32_t> TriangleOps::findAdjacentTriangles(SurfaceMeshDataContainer* sm,
                                                        int32_t triangleIndex,
                                                        int32_t label)
{
  std::vector<int32_t> adjacentTris;
  // Get the master list of triangles for the mesh
  DREAM3D::SurfaceMesh::FaceList_t::Pointer facesPtr = sm->getFaces();
//  DREAM3D::SurfaceMesh::Face_t* faces = facesPtr->GetPointer(0);
  IDataArray::Pointer flPtr = sm->getFaceData(DREAM3D::FaceData::SurfaceMeshFaceLabels);
  DataArray<int32_t>* faceLabelsPtr = DataArray<int32_t>::SafePointerDownCast(flPtr.get());
  int32_t* faceLabels = faceLabelsPtr->GetPointer(0);

  // Get the Triangle Neighbor Structure
  MeshFaceNeighbors::Pointer triNeighbors = sm->getMeshFaceNeighborLists();

  // For the specific triangle that was passed, get its neighbor list
  uint16_t count = triNeighbors->getNumberOfFaces(triangleIndex);
  int32_t* nList = triNeighbors->getNeighborListPointer(triangleIndex);

  if (count < 3)
  {
    std::cout << "Triangle Neighbor List had only " << count << " neighbors. Must be at least 3." << std::endl;
    BOOST_ASSERT(false);
  }
  else if (count == 3) // This triangle only has 3 neighbors so we are assuming all three have the same label set.
  {
    for (uint16_t n = 0; n < count; ++n)
    {
      adjacentTris.push_back(nList[n]);
    }
  }
  else
  {
    // Iterate over the indices to find triangles that match the label and are NOT the current triangle index
    for (uint16_t n = 0; n < count; ++n)
    {
      int32_t fl_0 = faceLabels[nList[n]*2];
      int32_t fl_1 = faceLabels[nList[n]*2 + 1];
      if ( (fl_0 == label || fl_1 == label)  && (nList[n] != triangleIndex) )
      {
        //  std::cout << "    Found Adjacent Triangle: " << t->tIndex << std::endl;
        adjacentTris.push_back(nList[n]);
        // ++index;
      }
    }
  }
  return adjacentTris;
}
开发者ID:chongbingbao,项目名称:DREAM3D,代码行数:51,代码来源:TriangleOps.cpp

示例15: SAdd

    int MMKVImpl::SAdd(DBID db, const Data& key, const DataArray& elements)
    {
        if (m_readonly)
        {
            return ERR_PERMISSION_DENIED;
        }
        int err = 0;

        RWLockGuard<MemorySegmentManager, WRITE_LOCK> keylock_guard(m_segment);
        EnsureWritableValueSpace();
        ObjectAllocator allocator = m_segment.MSpaceAllocator<Object>();
        StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, true, err)(std::less<Object>(), allocator);
        if (0 != err)
        {
            return err;
        }
        int inserted = 0;
        for (size_t i = 0; i < elements.size(); i++)
        {
            std::pair<StringSet::iterator, bool> ret = set->insert(Object(elements[i], true));
            if (ret.second)
            {
                m_segment.AssignObjectValue(*(ret.first), elements[i], true);
                inserted++;
            }
        }
        return inserted;
    }
开发者ID:shitfSign,项目名称:mmkv,代码行数:28,代码来源:t_set.cpp


注:本文中的DataArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。