本文整理汇总了C++中blitz::Array::extent方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::extent方法的具体用法?C++ Array::extent怎么用?C++ Array::extent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blitz::Array
的用法示例。
在下文中一共展示了Array::extent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: global_to_local
void GridDomain::global_to_local(
blitz::Array<double,1> const &global,
std::vector<blitz::Array<double,1>> &olocal)
{
if (olocal.size() != this->num_local_indices) {
fprintf(stderr, "MatrixDomainer::get_rows() had bad dimension 1 = %d (expected %ld)\n", olocal.extent(1), this->num_local_indices);
throw std::exception();
}
for (auto ii = olocal.begin(); ii != olocal.end(); ++ii) {
// Make sure it has the right dimensions
if (olocal[i].extent(0) != global.extent(0)) {
fprintf(stderr, "MatrixDomainer::get_rows() had bad dimension 0 = %d (expected %ld)\n", olocal.extent(0), global.extent(0));
throw std::exception();
}
}
// Copy out data, translating to local coordinates
for (int j=0; j < global.extent(0); ++j) {
int lindex[this->num_local_indices];
this->global_to_local(global(j), lindex);
for (int i=0; i<this->num_local_indices; ++i)
olocal[i](j) = lindex[i];
}
}
示例2: logLikelihood_
double bob::learn::em::GMMMachine::logLikelihood(const blitz::Array<double, 1> &x,
blitz::Array<double,1> &log_weighted_gaussian_likelihoods) const
{
// Check dimension
bob::core::array::assertSameDimensionLength(log_weighted_gaussian_likelihoods.extent(0), m_n_gaussians);
bob::core::array::assertSameDimensionLength(x.extent(0), m_n_inputs);
return logLikelihood_(x,log_weighted_gaussian_likelihoods);
}
示例3: setInputDivision
void Machine::setInputDivision (const blitz::Array<double,1>& v) {
if (m_weight.extent(0) != v.extent(0)) {
boost::format m("mismatch on the input division shape: expected a vector of size %d, but you input one with size = %d instead");
m % m_weight.extent(0) % v.extent(0);
throw std::runtime_error(m.str());
}
m_input_div.reference(bob::core::array::ccopy(v));
}
示例4: retval
blitz::Array<double,1> bob::example::library::reverse (const blitz::Array<double,1>& array){
// create new array in the desired shape
blitz::Array<double,1> retval(array.shape());
// copy data
for (int i = 0, j = array.extent(0)-1; i < array.extent(0); ++i, --j){
retval(j) = array(i);
}
// return the copied data
return retval;
}
示例5: setBiases
void Machine::setBiases (const blitz::Array<double,1>& bias) {
if (m_weight.extent(1) != bias.extent(0)) {
boost::format m("mismatch on the bias shape: expected a vector of size %d, but you input one with size = %d instead");
m % m_weight.extent(1) % bias.extent(0);
throw std::runtime_error(m.str());
}
m_bias.reference(bob::core::array::ccopy(bias));
}
示例6:
Machine::Machine(const blitz::Array<double,2>& weight)
: m_input_sub(weight.extent(0)),
m_input_div(weight.extent(0)),
m_bias(weight.extent(1)),
m_activation(boost::make_shared<bob::learn::activation::IdentityActivation>()),
m_buffer(weight.extent(0))
{
m_input_sub = 0.0;
m_input_div = 1.0;
m_bias = 0.0;
m_weight.reference(bob::core::array::ccopy(weight));
}
示例7:
double bob::learn::em::GMMMachine::logLikelihood(const blitz::Array<double, 2> &x) const {
// Check dimension
bob::core::array::assertSameDimensionLength(x.extent(1), m_n_inputs);
// Call the other logLikelihood_ (overloaded) function
double sum_ll = 0;
for (int i=0; i<x.extent(0); i++)
sum_ll+= logLikelihood_(x(i,blitz::Range::all()));
return sum_ll/x.extent(0);
}
示例8: check_dimensions
void check_dimensions(
std::string const &vname,
blitz::Array<T, rank> const &arr,
std::vector<int> const &dims)
{
for (int i=0; i<rank; ++i) {
if (dims[i] >= 0 && arr.extent(i) != dims[i]) {
fprintf(stderr,
"Error in %s: expected dimension #%d = %d (is %d instead)\n",
vname.c_str(), i, dims[i], arr.extent(i));
throw std::exception();
}
}
}
示例9: forward
void Machine::forward (const blitz::Array<double,1>& input, blitz::Array<double,1>& output) const {
if (m_weight.extent(0) != input.extent(0)) { //checks input dimension
boost::format m("mismatch on the input dimension: expected a vector of size %d, but you input one with size = %d instead");
m % m_weight.extent(0) % input.extent(0);
throw std::runtime_error(m.str());
}
if (m_weight.extent(1) != output.extent(0)) { //checks output dimension
boost::format m("mismatch on the output dimension: expected a vector of size %d, but you input one with size = %d instead");
m % m_weight.extent(1) % output.extent(0);
throw std::runtime_error(m.str());
}
forward_(input, output);
}
示例10: setWeights
void Machine::setWeights (const blitz::Array<double,2>& weight) {
if (weight.extent(0) != m_input_sub.extent(0)) { //checks 1st dimension
boost::format m("mismatch on the weight shape (number of rows): expected a weight matrix with %d row(s), but you input one with %d row(s) instead");
m % m_input_sub.extent(0) % weight.extent(0);
throw std::runtime_error(m.str());
}
if (weight.extent(1) != m_bias.extent(0)) { //checks 2nd dimension
boost::format m("mismatch on the weight shape (number of columns): expected a weight matrix with %d column(s), but you input one with %d column(s) instead");
m % m_bias.extent(0) % weight.extent(1);
throw std::runtime_error(m.str());
}
m_weight.reference(bob::core::array::ccopy(weight));
}
示例11: weights
void bob::learn::boosting::LUTTrainer::weightedHistogram(const blitz::Array<uint16_t,1>& features, const blitz::Array<double,1>& weights) const{
bob::core::array::assertSameShape(features, weights);
_gradientHistogram = 0.;
for (int i = features.extent(0); i--;){
_gradientHistogram((int)features(i)) += weights(i);
}
}
示例12: means
void bob::learn::em::GMMMachine::setMeans(const blitz::Array<double,2> &means) {
bob::core::array::assertSameDimensionLength(means.extent(0), m_n_gaussians);
bob::core::array::assertSameDimensionLength(means.extent(1), m_n_inputs);
for(size_t i=0; i<m_n_gaussians; ++i)
m_gaussians[i]->updateMean() = means(i,blitz::Range::all());
m_cache_supervector = false;
}
示例13: netcdf_write_blitz
void netcdf_write_blitz(NcVar *nc_var, blitz::Array<T, rank> const &val)
{
long counts[rank];
for (int i=0; i<rank; ++i) counts[i] = val.extent(i);
//printf("netcdf_write_blitz: %p %p\n", nc_var, val.data());
nc_var->put(val.data(), counts);
}
示例14: x
void bob::learn::em::GMMMachine::accStatistics_(const blitz::Array<double,2>& input, bob::learn::em::GMMStats& stats) const {
// iterate over data
blitz::Range a = blitz::Range::all();
for(int i=0; i<input.extent(0); ++i) {
// Get example
blitz::Array<double,1> x(input(i, a));
// Accumulate statistics
accStatistics_(x,stats);
}
}
示例15: array
int32_t bob::learn::boosting::LUTTrainer::bestIndex(const blitz::Array<double,1>& array) const{
double min = std::numeric_limits<double>::max();
int32_t minIndex = -1;
for (int i = 0; i < array.extent(0); ++i){
if (array(i) < min){
min = array(i);
minIndex = i;
}
}
return minIndex;
}