本文整理汇总了C++中Dimension类的典型用法代码示例。如果您正苦于以下问题:C++ Dimension类的具体用法?C++ Dimension怎么用?C++ Dimension使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dimension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scan_binary_onechr_intcovar_weighted_lowmem
// Scan a single chromosome with interactive covariates
// this version uses less memory but will be slower
// (since we need to work with each position, one at a time)
// and this one allows weights for the individuals (the same for all phenotypes)
//
// genoprobs = 3d array of genotype probabilities (individuals x genotypes x positions)
// pheno = matrix of numeric phenotypes (individuals x phenotypes)
// (no missing data allowed)
// addcovar = additive covariates (an intercept, at least)
// intcovar = interactive covariates (should also be included in addcovar)
// weights = vector of weights
//
// output = matrix of residual sums of squares (RSS) (phenotypes x positions)
//
// [[Rcpp::export]]
NumericMatrix scan_binary_onechr_intcovar_weighted_lowmem(const NumericVector& genoprobs,
const NumericMatrix& pheno,
const NumericMatrix& addcovar,
const NumericMatrix& intcovar,
const NumericVector& weights,
const int maxit=100,
const double tol=1e-6,
const double qr_tol=1e-12,
const double eta_max=30.0)
{
const int n_ind = pheno.rows();
if(Rf_isNull(genoprobs.attr("dim")))
throw std::invalid_argument("genoprobs should be a 3d array but has no dim attribute");
const Dimension d = genoprobs.attr("dim");
if(d.size() != 3)
throw std::invalid_argument("genoprobs should be a 3d array");
const int n_pos = d[2];
const int n_phe = pheno.cols();
if(n_ind != d[0])
throw std::range_error("nrow(pheno) != nrow(genoprobs)");
if(n_ind != addcovar.rows())
throw std::range_error("nrow(pheno) != nrow(addcovar)");
if(n_ind != intcovar.rows())
throw std::range_error("nrow(pheno) != nrow(intcovar)");
NumericMatrix result(n_phe, n_pos);
for(int pos=0; pos<n_pos; pos++) {
Rcpp::checkUserInterrupt(); // check for ^C from user
// form X matrix
NumericMatrix X = formX_intcovar(genoprobs, addcovar, intcovar, pos, true);
for(int phe=0; phe<n_phe; phe++) {
// do regression
result(phe,pos) = calc_ll_binreg_weighted(X, pheno(_,phe), weights, maxit, tol, qr_tol, eta_max);
}
}
return result;
}
示例2: copyDatabaseData
void IteratorBase::copyDatabaseData(PointBuffer& source,
PointBuffer& destination,
Dimension const& dest_dim,
boost::uint32_t source_starting_position,
boost::uint32_t destination_starting_position,
boost::uint32_t howMany)
{
boost::optional<Dimension const&> source_dim = source.getSchema().getDimensionOptional(dest_dim.getName());
if (!source_dim)
{
return;
}
for (boost::uint32_t i = 0; i < howMany; ++i)
{
if (dest_dim.getInterpretation() == source_dim->getInterpretation() &&
dest_dim.getByteSize() == source_dim->getByteSize() &&
pdal::Utils::compare_distance(dest_dim.getNumericScale(), source_dim->getNumericScale()) &&
pdal::Utils::compare_distance(dest_dim.getNumericOffset(), source_dim->getNumericOffset()) &&
dest_dim.getEndianness() == source_dim->getEndianness()
)
{
// FIXME: This test could produce false positives
boost::uint8_t* source_position = source.getData(source_starting_position+i) + source_dim->getByteOffset();
boost::uint8_t* destination_position = destination.getData(destination_starting_position + i) + dest_dim.getByteOffset();
memcpy(destination_position, source_position, source_dim->getByteSize());
}
else
{
PointBuffer::scaleData(source,
destination,
*source_dim,
dest_dim,
source_starting_position + i,
destination_starting_position + i);
}
}
}
示例3: addDimension
//add dimension into cube if add success return true else return false
bool XCube::addDimension(const Dimension& dimension)
{
if(this->getDimension(dimension.getName()))
{
Dimension *tmpdimension=new Dimension;
*tmpdimension=dimension;
tmpdimension->setCubeDimension(this);
this->_dimensions.push_back(tmpdimension);
return true;
}
return false;
}
示例4: fillInDimension
static Dimension fillInDimension(const Dimension& newSize, const Dimension& inputSize)
{
if(newSize.product() == inputSize.product())
{
return newSize;
}
Dimension size(newSize);
// fill in remaining non-empty dimensions
size_t remaining = inputSize.product() / size.product();
size_t dimension = size.size();
assert(inputSize.product() % size.product() == 0);
// TODO: be smarter about the remainder
for(size_t d = dimension; d < inputSize.size(); ++d)
{
if(remaining <= 1)
{
break;
}
size.push_back(remaining);
remaining /= remaining;
}
assert(size.product() == inputSize.product());
return size;
}
示例5: asyncUpdatePopup
void GuiCompleter::asyncUpdatePopup()
{
Cursor cur = gui_->bufferView().cursor();
if (!cur.inset().completionSupported(cur)
|| !cur.bv().paragraphVisible(cur)) {
popupVisible_ = false;
return;
}
// get dimensions of completion prefix
Dimension dim;
int x;
int y;
cur.inset().completionPosAndDim(cur, x, y, dim);
// and calculate the rect of the popup
QRect rect;
if (popup()->layoutDirection() == Qt::RightToLeft)
rect = QRect(x + dim.width() - 200, y - dim.ascent() - 3, 200, dim.height() + 6);
else
rect = QRect(x, y - dim.ascent() - 3, 200, dim.height() + 6);
// Resize the columns in the popup.
// This should really be in the constructor. But somehow the treeview
// has a bad memory about it and we have to tell him again and again.
QTreeView * listView = static_cast<QTreeView *>(popup());
listView->header()->setStretchLastSection(false);
listView->header()->setResizeMode(0, QHeaderView::Stretch);
listView->header()->setResizeMode(1, QHeaderView::Fixed);
listView->header()->resizeSection(1, 22);
// show/update popup
complete(rect);
}
示例6: while
bool Schema::setDimension(Dimension const& dim)
{
// Try setting based on UUID first if it's there and not null.
if (dim.getUUID() != boost::uuids::nil_uuid())
{
schema::index_by_uid& id_index = m_index.get<schema::uid>();
schema::index_by_uid::const_iterator id = id_index.find(dim.getUUID());
if (id != id_index.end())
{
id_index.replace(id, dim);
return true;
}
}
schema::index_by_name& name_index = m_index.get<schema::name>();
schema::index_by_name::iterator it = name_index.find(dim.getName());
// FIXME: If there are two dimensions with the same name here, we're
// screwed if they both have the same namespace too
if (it != name_index.end())
{
while (it != name_index.end())
{
if (boost::equals(dim.getNamespace(), it->getNamespace()))
{
name_index.replace(it, dim);
return true;
}
++it;
}
}
else
{
std::ostringstream oss;
oss << "Dimension with name '" << dim.getName() << "' not found, unable to Schema::setDimension";
throw dimension_not_found(oss.str());
}
return true;
}
示例7: getNumberofMisplacedTile
unsigned PuzzleWindow::getNumberofMisplacedTile(Board testBoard, Board goalBoard)
{
Dimension theDimension;
theDimension = testBoard.getDimension();
unsigned ROWS = theDimension.getRow();
unsigned COLS = theDimension.getCol();
unsigned start = 1;
unsigned counter =0;
for(unsigned i = 0;i < ROWS;++i)
{
for(unsigned j = 0;j < COLS;++j)
{
//if(start != testBoard[i][j].getNumber())
{
counter++;
}
start++;
}
}
return counter;
}
示例8: createExample52
NUMLDocument* createExample52()
{
NUMLDocument* doc = new NUMLDocument();
ResultComponent* r = doc->createResultComponent();
r->setId("main_fitting_result");
DimensionDescription* d = r->getDimensionDescription();
TupleDescription* t = d->createTupleDescription();
t->setName("Main");
AtomicDescription* a = t->createAtomicDescription();
a->setName( "Objective Value");
a->setValueType("float");
a = t->createAtomicDescription();
a->setName( "Root Mean Square");
a->setValueType("float");
a = t->createAtomicDescription();
a->setName( "Standard Deviation");
a->setValueType("float");
Dimension* dim = r->getDimension();
Tuple* tuple = dim->createTuple();
AtomicValue* val = tuple->createAtomicValue();
val->setValue("12.5015");
val = tuple->createAtomicValue();
val->setValue("0.158123");
val = tuple->createAtomicValue();
val->setValue("0.159242");
return doc;
}
示例9: MapEditMainMenu
bool NewMapState::handleEvent(StiGame::EventThrower *src, StiGame::EventArgs *evt)
{
if(src == &btnBack)
{
running = false;
MapEditMainMenu *state = new MapEditMainMenu();
viewport->push(state);
return true;
}
else if(src == &btnCreate)
{
running = false;
Dimension *mapSize = (dynamic_cast<MapSizeVO*>(listSizes.getSelectedItem()))->getDimension();
//STRData::MapData *mp = new STRData::MapData(mapSize->getWidth(), mapSize->getHeight());
//todo
MEMap *map = new MEMap(mapSize->getWidth(), mapSize->getHeight());
MapEditState *state = new MapEditState(map);
viewport->push(state);
return true;
}
}
示例10: Compress
std::string Compressor::Compress(Point &point, Dimension &dimension) const {
assert((dimension.num_rows >= 1) && (dimension.num_columns >= 1));
if ((dimension.num_rows == 1) && (dimension.num_columns == 1)) {
return data_.Get(point);
}
std::string res;
auto top_left_dim = dimension.TopLeft();
res += Compress(point, top_left_dim);
if (dimension.num_columns > 1) {
auto top_right_begin = ComputeTopRight(point, top_left_dim);
auto top_right_dim = dimension.TopRight();
res += Compress(top_right_begin, top_right_dim);
}
if (dimension.num_rows > 1) {
auto bottom_left_begin = ComputeBottomLeft(point, top_left_dim);
auto bottom_left_dim = dimension.BottomLeft();
res += Compress(bottom_left_begin, bottom_left_dim);
}
if ((dimension.num_columns > 1) && (dimension.num_rows > 1)) {
auto bottom_right_begin = ComputeBottomRight(point, top_left_dim);
auto bottom_right_dim = dimension.BottomRight();
res += Compress(bottom_right_begin, bottom_right_dim);
}
if (AllSame(res)) {
char data[2]{res[0], '\0'};
return std::string(data);
}
return "D" + res;
}
示例11: makePlaneAroundDimensionEnd
BoxT
makePlaneAroundDimensionEnd(
const Dimension<T>& dim,
const typename Dimension<T>::End end) const
{
double inf = std::numeric_limits<double>::infinity();
Vector<DIM, T> lower(-inf), upper(inf);
lower[dim.direction()] = dim(end);
upper[dim.direction()] = dim(end);
// now convert them
PointT minimum = VectorOps<DIM, T>::toBoostPoint(
lower);
PointT maximum = VectorOps<DIM, T>::toBoostPoint(
upper);
return BoxT(minimum, maximum);
}
示例12: evalpos
size_t Dimension::evalpos (const Dimension & d) const
{
size_t n= size ();
if (d.size () != n)
throw ErrBadSubscript;
size_t pos= d [0];
if (pos > dim [0])
throw ErrBadSubscript;
for (size_t i= 1; i < n; ++i)
{
if (d [i] > dim [i] )
throw ErrBadSubscript;
pos*= dim [i] + 1;
pos+= d [i];
}
return pos;
}
示例13: metrics
void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const
{
Dimension dim0, dim1;
// FIXME: for an unknown reason the cells must be set directly
// after the StyleChanger and cannot be set after the if case
if (kind_ == DBINOM) {
StyleChanger dummy(mi.base, LM_ST_DISPLAY);
cell(0).metrics(mi, dim0);
cell(1).metrics(mi, dim1);
} else if (kind_ == TBINOM) {
StyleChanger dummy(mi.base, LM_ST_SCRIPT);
cell(0).metrics(mi, dim0);
cell(1).metrics(mi, dim1);
} else {
FracChanger dummy(mi.base);
cell(0).metrics(mi, dim0);
cell(1).metrics(mi, dim1);
}
dim.asc = dim0.height() + 4 + 5;
dim.des = dim1.height() + 4 - 5;
dim.wid = max(dim0.wid, dim1.wid) + 2 * dw(dim.height()) + 4;
metricsMarkers2(dim);
}
示例14: parseFactor
Dimension UnitSystem::parse(const std::string& dimension) const {
const size_t divCount = std::count( dimension.begin() , dimension.end() , '/' );
if( divCount > 1 )
throw std::invalid_argument("Dimension string can only have one division sign '/'");
const bool haveDivisor = divCount == 1;
if( !haveDivisor ) return parseFactor( dimension );
std::vector<std::string> parts;
boost::split(parts , dimension , boost::is_any_of("/"));
Dimension dividend = parseFactor( parts[0] );
Dimension divisor = parseFactor( parts[1] );
if (dividend.getSIOffset() != 0.0 || divisor.getSIOffset() != 0.0)
throw std::invalid_argument("Composite dimensions cannot currently require a conversion offset");
return Dimension::newComposite( dimension, dividend.getSIScaling() / divisor.getSIScaling() );
}
示例15: return
template<class Type> bool Dimension<Type>::operator >=(Dimension<Type> dim){
return (dimension >= dim.getDimension());
}