float cMatrix::Minor( int nRow, int nCol ) { cMatrix mat(Dimension() - 1); int nMinorRow = 0; int nMinorCol = 0; for (int i = 0; i < Dimension(); ++i) { if (nRow == i) { continue; } nMinorCol = 0; for (int j = 0; j < Dimension(); ++j) { if (nCol == j) { continue; } mat[nMinorRow][nMinorCol] = (*this)[i][j]; ++nMinorCol; } ++nMinorRow; } return mat.Determinent(); }
int GridSampleHolder::Add(const Sample & sample) { if(sample.coordinate.Dimension() != Dimension()) return 0; vector<int> cell_index(Dimension()); if(! LocateCell(sample, cell_index)) { return 0; } Cell cell; if(!_cells.Get(cell_index, cell)) { return 0; } #ifndef _ALLOW_MULTIPLE_SAMPLES_PER_CELL if(cell.samples.size() > 0) { return 0; } else #endif { cell.samples.push_back(&sample); if(!_cells.Put(cell_index, cell)) return 0; return 1; } }
/* ************************************************************************* * * Read data from restart database. * ************************************************************************* */ void CVODEModel::getFromRestart() { std::shared_ptr<Database> root_db( RestartManager::getManager()->getRootDatabase()); if (!root_db->isDatabase(d_object_name)) { TBOX_ERROR("Restart database corresponding to " << d_object_name << " not found in the restart file."); } std::shared_ptr<Database> db(root_db->getDatabase(d_object_name)); int ver = db->getInteger("CVODE_MODEL_VERSION"); if (ver != CVODE_MODEL_VERSION) { TBOX_ERROR( d_object_name << ": " << "Restart file version different than class version."); } d_initial_value = db->getDouble("d_initial_value"); d_scalar_bdry_edge_conds = db->getIntegerVector("d_scalar_bdry_edge_conds"); d_scalar_bdry_node_conds = db->getIntegerVector("d_scalar_bdry_node_conds"); if (d_dim == Dimension(2)) { d_bdry_edge_val = db->getDoubleVector("d_bdry_edge_val"); } else if (d_dim == Dimension(3)) { d_scalar_bdry_face_conds = db->getIntegerVector("d_scalar_bdry_face_conds"); d_bdry_face_val = db->getDoubleVector("d_bdry_face_val"); } }
void CVODEModel::printClassData( ostream& os) const { fflush(stdout); int j; os << "ptr CVODEModel = " << (CVODEModel *)this << endl; os << "d_object_name = " << d_object_name << endl; os << "d_soln_cur_id = " << d_soln_cur_id << endl; os << "d_soln_scr_id = " << d_soln_scr_id << endl; os << "d_initial_value = " << d_initial_value << endl; os << "Boundary Condition data..." << endl; if (d_dim == Dimension(2)) { for (j = 0; j < static_cast<int>(d_scalar_bdry_edge_conds.size()); ++j) { os << " d_scalar_bdry_edge_conds[" << j << "] = " << d_scalar_bdry_edge_conds[j] << endl; if (d_scalar_bdry_edge_conds[j] == BdryCond::DIRICHLET) { os << " d_bdry_edge_val[" << j << "] = " << d_bdry_edge_val[j] << endl; } } os << endl; for (j = 0; j < static_cast<int>(d_scalar_bdry_node_conds.size()); ++j) { os << " d_scalar_bdry_node_conds[" << j << "] = " << d_scalar_bdry_node_conds[j] << endl; os << " d_node_bdry_edge[" << j << "] = " << d_node_bdry_edge[j] << endl; } } else if (d_dim == Dimension(3)) { for (j = 0; j < static_cast<int>(d_scalar_bdry_face_conds.size()); ++j) { os << " d_scalar_bdry_face_conds[" << j << "] = " << d_scalar_bdry_face_conds[j] << endl; if (d_scalar_bdry_face_conds[j] == BdryCond::DIRICHLET) { os << " d_bdry_face_val[" << j << "] = " << d_bdry_face_val[j] << endl; } } os << endl; for (j = 0; j < static_cast<int>(d_scalar_bdry_edge_conds.size()); ++j) { os << " d_scalar_bdry_edge_conds[" << j << "] = " << d_scalar_bdry_edge_conds[j] << endl; os << " d_edge_bdry_face[" << j << "] = " << d_edge_bdry_face[j] << endl; } os << endl; for (j = 0; j < static_cast<int>(d_scalar_bdry_node_conds.size()); ++j) { os << " d_scalar_bdry_node_conds[" << j << "] = " << d_scalar_bdry_node_conds[j] << endl; os << " d_node_bdry_face[" << j << "] = " << d_node_bdry_face[j] << endl; } } }
/****************************************************************************************** * void K_MeansPredict::Output( ostream& stream ) const * purpose: * outputs predictor to stream * * 02.18.2006 djh added isnan and isinf flags in _upper and lower pi prints * 03.08.2006 djh replaced _totalUpper/_totalLowerConfBound with _totalBoundStub * added isnan and isinf flags to _key_variances prints *****************************************************************************************/ void K_MeansPredict::Output( ostream& stream ) const { stream << setw(15) << _k << setw(15) << Dimension() << endl; stream << _withinClusterScatter << endl; // for( int i=0;i<_means.size(); i++ ) { for(int j=0; j<Dimension(); j++) { stream << setw(15) << _means[i][j]; } stream << endl; } // for( int i=0;i<_key_supports.size(); i++ ) { stream << setw(15) << _key_supports[i]; } stream << endl; // for( int i=0;i<_key_means.size(); i++ ) { stream << setw(15) << _key_means[i]; } stream << endl; // for( int i=0;i<_key_variances.size(); i++ ){ if( isinf(abs(_key_variances[i])) || isnan(_key_variances[i]) ) stream << setw(15) << 0.0; else stream << setw(15) << _key_variances[i]; } stream << endl; // for( int i=0;i<_errMean.size(); i++ ) { stream << setw(15) << _errMean[i]; } stream << endl; // for( int i=0;i<_upperConfBound.size(); i++ ) { if( isinf(abs(_upperConfBound[i])) || isnan(_upperConfBound[i]) ) stream << setw(15) << 0.0; else stream << setw(15) << _upperConfBound[i]; } stream << endl; // for( int i=0;i<_lowerConfBound.size(); i++ ) { if( isinf(abs(_lowerConfBound[i])) || isnan(_lowerConfBound[i]) ) stream << setw(15) << 0.0; else stream << setw(15) << _lowerConfBound[i]; } stream << endl; //stream << setw(15) << _totalErrMean << setw(15) << _totalLowerConfBound << setw(15) << _totalUpperConfBound; stream << setw(15) << _totalErrMean << setw(15) << _totalBoundStub; }
cMatrix cMatrix::Adjoint() { cMatrix matRet(Dimension()); for (int i = 0; i < Dimension(); ++i) { for (int j = 0; j < Dimension(); ++j) { matRet[i][j] = Cofactor(j, i); } } return matRet; }
cMatrix cMatrix::Transpose() { cMatrix matRet(Dimension()); for (int i = 0; i < Dimension(); ++i) { for (int j = 0; j < Dimension(); ++j) { matRet[i][j] = (*this)[j][i]; } } return matRet; }
bool cMatrix::operator==( cMatrix mat ) { for (int i = 0; i < Dimension(); ++i) { for (int j = 0; j < Dimension(); ++j) { if(fabs((*this)[i][j] - mat[i][j]) > 0.00001f) return false; } } return true; }
void ChessVector::set_up() { as_vector.zero(); Species setup[8] = {rook, knight, bishop, queen, king, bishop, knight, rook}; for(int file = 0; file < 8; file++) { component(Dimension(0, file, black, setup[file])) = 1.0; // black back component(Dimension(1, file, black, pawn)) = 1.0; // black fore component(Dimension(6, file, white, pawn)) = 1.0; // white back component(Dimension(7, file, white, setup[file])) = 1.0; // white fore } }
/** * Initalizes the game * @param newLineInterval The time in miliseconds, when a new line of letters * should be created on the gametable */ Game::Game(unsigned int newLineInterval) : dict(WORD_MIN_LENGTH, WORD_MAX_LENGTH) // horiz vert vorne breite hoehe tiefe , backGround(Point(-32.0f, 0.0f, -32.0f), Dimension(64.0f, 0.0f, 64.0f)) //point(x, y, z), Dimension(x, y, z) , gameTable(Point(0.0f, 0.0f, -9.0f), Dimension(6.0f, 0.5f, (6.0f/8.0f)*GAMETABLE_ROWS_NUM)) , scorePanel(Point(0.0f, 0.0f, -11.0f), Dimension(6.0f, 0.5f, 1.0f)) , letterShelf(Point(0.0f, 0.0f, 0.0f), Dimension(6.0f, 0.5f, 1.0f)) { this->dict.load(DICTIONARY_PATH); this->newLineInterval = newLineInterval; this->gameTable.addNewLine(); this->initLetterPoints(); }
/***************************************************************************************** * void K_MeansPredict::OutputMeans( ostream& stream )const * * Purpose: Print mean descriptions * input: * stream: output stream * *****************************************************************************************/ void K_MeansPredict::OutputMeans( ostream& stream )const{ stream << setw(15) << _k << setw(15) << Dimension()<< endl; for( int i=0; i<_k; i++ ) { for( int j=0; j<Dimension(); j++ ) { stream << setw(15) << _means[i][j]; } stream << setw(15) << _key_supports[i]; stream << setw(15) << _key_means[i]; stream << setw(15) << _key_variances[i]; stream << endl; } }
cMatrix cMatrix::operator-( cMatrix mat ) { cMatrix matRet(Dimension()); for (int i = 0; i < Dimension(); ++i) { for (int j = 0; j < Dimension(); ++j) { matRet[i][j] = (*this)[i][j] - mat[i][j]; } } return matRet; }
cMatrix cMatrix::operator*( float f ) { cMatrix matRet(Dimension()); for (int i = 0; i < Dimension(); ++i) { for (int j = 0; j < Dimension(); ++j) { matRet[i][j] = (*this)[i][j] * f; } } return matRet; }
void DrawCheckbox(StyledWindow *window, wxGraphicsContext *g) const { static const int radius = 0; static const wxColour borderColor = "#1c1617"; static const wxColour bottomHighlight = "#46474B"; static const wxColour topHighlight = "#606268"; static const wxColour backgroundColor = "#2b2a2a"; static const wxColour checkedBorder = "#2f4b20"; const int h = window->GetSize().GetHeight(); const int w = h - 1; DrawRectangleInstruction bottomHighlightInstruction(DrawShapeInstruction::Params() .SetColor(bottomHighlight) .SetCornerRadius(radius) .SetRect(DimRect(0, 0, Dimension(w, 0), Dimension(h, 0.0)))); DrawRectangleInstruction borderInstruction = DrawRectangleInstruction(DrawShapeInstruction::Params() .SetColor(borderColor) .SetCornerRadius(radius) .SetRect(DimRect(0, 0, Dimension(w, 0), Dimension(h-1, 0)))); DrawRectangleInstruction backgroundColorInstruction(DrawShapeInstruction::Params() .SetColor(backgroundColor) .SetCornerRadius(radius) .SetRect(DimRect(1, 1, Dimension(w-2, 0), Dimension(h-3, 0)))); GradientDefinitionPtr gradient = std::make_shared<LinearGradientDefinition>(LinearGradientDefinition::Direction::VERTICAL); gradient->AddColorStop(0, "#61ae36"); gradient->AddColorStop(1, "#3b6b21"); DrawRectangleInstruction checkedBackgroundInstruction(DrawShapeInstruction::Params() .SetGradientDefinition(gradient) .SetCornerRadius(radius) .SetRect(DimRect(2, 2, Dimension(w-4, 0), Dimension(h-5, 0)))); DrawRectangleInstruction checkedBorderInstruction(DrawShapeInstruction::Params() .SetColor(checkedBorder) .SetCornerRadius(radius) .SetRect(DimRect(1, 1, Dimension(w-2, 0), Dimension(h-3, 0)))); bottomHighlightInstruction.Draw(g, window->GetSize()); borderInstruction.Draw(g, window->GetSize()); backgroundColorInstruction.Draw(g, window->GetSize()); if (static_cast<StyledCheckBox*>(window)->IsChecked()) { checkedBackgroundInstruction.Draw(g, window->GetSize()); } }
/* ************************************************************************* * * Get data from input database. * ************************************************************************* */ void CVODEModel::getFromInput( std::shared_ptr<Database> input_db, bool is_from_restart) { NULL_USE(is_from_restart); d_initial_value = input_db->getDoubleWithDefault("initial_value", 0.0); IntVector periodic(d_grid_geometry->getPeriodicShift(IntVector(d_dim, 1))); int num_per_dirs = 0; for (int id = 0; id < d_dim.getValue(); ++id) { if (periodic(id)) ++num_per_dirs; } if (input_db->keyExists("Boundary_data")) { std::shared_ptr<Database> boundary_db( input_db->getDatabase("Boundary_data")); if (d_dim == Dimension(2)) { CartesianBoundaryUtilities2::getFromInput(this, boundary_db, d_scalar_bdry_edge_conds, d_scalar_bdry_node_conds, periodic); } else if (d_dim == Dimension(3)) { CartesianBoundaryUtilities3::getFromInput(this, boundary_db, d_scalar_bdry_face_conds, d_scalar_bdry_edge_conds, d_scalar_bdry_node_conds, periodic); } } else { TBOX_WARNING( d_object_name << ": " << "Key data `Boundary_data' not found in input. " << endl); } #ifdef USE_FAC_PRECONDITIONER d_use_neumann_bcs = input_db->getBoolWithDefault("use_neumann_bcs", d_use_neumann_bcs); d_print_solver_info = input_db->getBoolWithDefault("print_solver_info", d_print_solver_info); #endif }
void RadioButton::positionRadioButton() { radioButtonPosition = createAlignedPosition( getRadioButtonAlignment(),getInnerRectangle(), Dimension(getRadioButtonRadius() * 2, getRadioButtonRadius() * 2)); radioButtonPosition = Point( radioButtonPosition.getX() + (getRadioButtonRadius() ), radioButtonPosition.getY() + (getRadioButtonRadius() )); radioButtonRect = Rectangle(Point( radioButtonPosition.getX() - getRadioButtonRadius(), radioButtonPosition.getY() - getRadioButtonRadius()), Dimension(getRadioButtonRadius() * 2, getRadioButtonRadius() * 2)); }
float cMatrix::Determinent() { if(Dimension() == 2) { return (*this)[0][0] * (*this)[1][1] - (*this)[1][0] * (*this)[0][1]; } float fDeterminent = 0.0f; for (int i = 0; i < Dimension(); ++i) { fDeterminent += ((*this)[i][0] * Cofactor(i, 0)); } return fDeterminent; }
void Vector::Dimension(int d, double value) { int original = dim; Dimension(d); for (int i = original; i < dim; i++) data[i] = value; }
void Vector::Stack(const Vector &v) { int end = dim; Dimension(dim + v.dim); for (int i = 0; i < v.dim; i++) data[i + end] = v[i]; }
ON_BOOL32 ON_Geometry::SwapCoordinates( int i, int j // indices of coords to swap ) { ON_BOOL32 rc = false; const int dim = Dimension(); if ( dim > 0 && dim <= 3 && i >= 0 && i < 3 && j >= 0 && j < 3 ) { if ( i == j ) { rc = true; } else { int k; ON_Xform swapij(0.0); for ( k = 0; k < 4; k++ ) { if ( i == k ) swapij[k][j] = 1.0; else if ( j == k ) swapij[k][i] = 1.0; else swapij[k][k] = 1.0; } rc = Transform( swapij ); } } return rc; }
// TODO: Each data set needs dimension information. Analysis::RetType Analysis_Spline::Analyze() { double mmin, mmax; int msize; for (unsigned int idx = 0; idx < input_dsets_.size(); idx++) { DataSet_1D const& ds = static_cast<DataSet_1D const&>(*input_dsets_[idx]); if (useDefaultMin_) mmin = meshmin_; else mmin = ds.Min(); if (useDefaultMax_) mmax = meshmax_; else mmax = ds.Max(); if (meshfactor_ > 0) msize = (int)((double)ds.Size() * meshfactor_); else msize = meshsize_; // Set up output dimension mprintf("\t%s: Setting mesh from %f->%f, size=%i,", ds.legend(), mmin, mmax, msize); output_dsets_[idx]->SetDim( Dimension::X, Dimension(mmin, (mmax - mmin)/(double)msize, ds.Dim(0).Label()) ); output_dsets_[idx]->CalculateMeshX(msize, mmin, mmax); mprintf(" set min=%f, set step=%f\n", ds.Dim(0).Min(), ds.Dim(0).Step()); // Calculate mesh Y values. output_dsets_[idx]->SetSplinedMesh( ds ); // DEBUG //for (unsigned int i = 0; i < output_dsets_[idx]->Size(); i++) // mprintf("\t%12.4f %12.4g\n", output_dsets_[idx]->X(i), output_dsets_[idx]->Y(i)); } return Analysis::OK; }
bool VECTOR3::IsSame(VECTOR3& a) { for(int i = 0; i < Dimension(); i++) if(vec[i] != a(i)) return false; return true; }
void ScrollPane::setSize( const Dimension &size ) { Widget::setSize(size); updateScrollBars(); pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); }
void FloatVector::SetMultiple(double k, FloatVector & v) { Dimension(v.dim); for (int i = 0; i < dim; i++) data[i] = k * v[i]; }
/*! * Take as parameters:\n * The label of the set * The dimension of the vector space.\n */ ChebyshevSet(const std::string _setLabel, my::integer _vecDim ): setLabel_(_setLabel), vecDim_(_vecDim), num_cheb_set_(2) { memorySize_= NumOfSets()*3*Dimension(); ///The linear memory blocks tries to allocate the appropiate ammount of memory linearMemBlock_=new my::scalar [ memorySize_ ]; if(linearMemBlock_ == NULL) { std::cerr<<"Unable to allocate the ammount of requested memory: " << sizeof(my::scalar)*memorySize_/1048576<<" Mb"<<std::endl <<"the program will be terminated "<<std::endl; std::exit(-1); } //Initialize each of the requested chebyshev set, (by default 2) ChebVecs_= std::vector< std::vector< my::scalar* > >( NumOfSets() ); for(my::integer i=0;i<NumOfSets();i++) { //Each of this sets has kpm::VECPERSET=3 Chebyshev vectors ChebVecs_[i]=std::vector< my::scalar* >(kpm::VECPERSET); //Which are setted intercalated into a huge block of memory for(my::integer j=0;j<kpm::VECPERSET;j++) ChebVecs_[i][j]=&linearMemBlock_[NumOfSets()*j+i]; } }
bool ON_BezierCage::GetCV( int i, int j, int k, ON::point_style style, double* Point ) const { const double* cv = CV(i,j,k); if ( !cv ) return false; int dim = Dimension(); double w = ( IsRational() ) ? cv[dim] : 1.0; switch(style) { case ON::euclidean_rational: Point[dim] = w; // no break here case ON::not_rational: if ( w == 0.0 ) return false; w = 1.0/w; while(dim--) *Point++ = *cv++ * w; break; case ON::homogeneous_rational: Point[dim] = w; memcpy( Point, cv, dim*sizeof(*Point) ); break; default: return false; } return true; }
void ScrollPane::add( Widget *widget ) { pChildContent->add(widget); pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); updateScrollBars(); }
ISymbol::ISymbol() { Parsed()=0; Visited()=0; Type()=(SymbolType) -1; ListType()=unknown_; Dimension()=0; SimpleType()=true; Required()=false; Abstract()=false; Compositor()=0; DerivedType() = XercesAdditions::DERIVATION_NONE; XercesType() = XercesAdditions::NO_DECLARATION; Global()=false; SqlCount()=0; SubstitutionGroupAffiliation().clear(); symbols.push_back(this); Variable()=NULL; SimpleContent()=false; List()=false; Atomic()=false; Level()=0; ListSize()=0; intrusive_ptr_add_ref((IExpress *) symbols.back().get()); }
Dimension NameRepo::dimension(const vespalib::string &name) { size_t id = _dimensionNames.resolve(name); LOG(debug, "dimension name %s -> %zu", name.c_str(), id); return Dimension(id); }
// set matrix to identity matrix void MATRIX4::Identity() { for (int i = 0; i < Dimension(); i++) { mat[i].Zero(); mat[i][i] = 1.0; }; }