本文整理汇总了C++中Lattice类的典型用法代码示例。如果您正苦于以下问题:C++ Lattice类的具体用法?C++ Lattice怎么用?C++ Lattice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Lattice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Sentence::Sentence(const Lattice &l)
{
int i,n = l.get_word_count();
syllables.resize(n); // pre-allocation
for (i = 0;i < n;i ++) {
const WordEntryRefs &wers = l.get_we(i);
for (int j = 0;j < wers.size();j ++) {
const WordEntry *pwe = wers[j];
vector<strid> vsy;
pwe->node.node->get_syllables(vsy);
if (syllables.size() < i+vsy.size())
syllables.resize(i+vsy.size());
Sentence::Syllable sy;
sy.span = 1;
sy.sent_ = this;
sy.start = 0;
for (int pos = 0;pos < vsy.size(); pos ++) {
sy.id = vsy[pos];
sy.cid = get_ngram()[get_std_syllable(get_ngram()[sy.id])];
syllables[i+pos] = sy;
}
}
}
int start = 0;
for (i = 0;i < syllables.size();i ++) {
if (i > 0) {
sent_ += " ";
start ++;
}
string s = get_ngram()[syllables[i].id];
sent_ += s;
syllables[i].start = start;
start += s.size();
}
}
示例2: ZPAIRP
void TransfererRunner::putTargetForm_(Lattice& lattice, Lattice::EdgeDescriptor edge, zvalue surf) {
// could be a form or a token
bool isForm = ZPAIRP(surf);
std::string category =
(isForm ? zvalue_to_string(ZPAIRC(surf)->getSecond()) : "T");
zvalue text =
(isForm ? ZPAIRC(surf)->getFirst() : surf);
LayerTagCollection tags =
lattice.getLayerTagManager().createTagCollection(
isForm ? targetFormTags_ : targetTokenTags_);
AnnotationItem annotationItem(category, StringFrag(zvalue_to_string(text)));
lattice.getAnnotationItemManager().setValue(
annotationItem, "SurfacePosition", formsCounter_++);
Lattice::EdgeSequence::Builder builder(lattice);
builder.addEdge(edge);
Lattice::VertexDescriptor fromVertex = lattice.getEdgeSource(edge);
Lattice::VertexDescriptor toVertex = lattice.getEdgeTarget(edge);
lattice.addEdge(
fromVertex,
toVertex,
annotationItem,
tags,
builder.build());
}
示例3: CloverLeaf2x2
void CloverLeaf2x2(Lattice& lattice, Matrix& pl, int* pos, int mu, int nu)
{
Matrix P0,P1,P2,P3;
// 1x2 size
P0.ZeroMatrix();
P1.ZeroMatrix();
P2.ZeroMatrix();
P3.ZeroMatrix();
// each direction could be {0,1,2,3,4,5,6,7} coresponding to
// the directions {n_x, n_y, n_z, n_t, -n_x, -n_y, -n_z, -n_t}
int dirs0[8]={mu,mu, nu, nu, mu+4,mu+4, nu+4, nu+4};
lattice.PathOrdProdPlus(P0, pos, dirs0, 8);
int dirs1[8]={nu+4, nu+4, mu+4, mu+4, nu, nu, mu,mu };
lattice.PathOrdProdPlus(P1, pos, dirs1, 8);
int dirs2[8]={nu, nu, mu+4, mu+4, nu+4, nu+4, mu, mu };
lattice.PathOrdProdPlus(P2, pos, dirs2, 8);
int dirs3[8]={mu,mu, nu+4, nu+4, mu+4, mu+4, nu, nu };
lattice.PathOrdProdPlus(P3, pos, dirs3, 8);
P0 -= P1;
P0 += P2;
P0 -= P3;
P0 *= 1.0/16;
moveMem((Float*) &pl,(Float*) &P0, 18 * sizeof(Float) );
}
示例4: get_alternativelikelyhood_coordinates
int get_alternativelikelyhood_coordinates(float* Matrix, std::vector<double>& coordinates, std::vector<double>& likelyhoods, Lattice lattice, int distance, double& H_tot, int K_iteration)
{
int D;
if (lattice.get_dimensions() == 2)
{
D = lattice.area();
}
else
{
D = lattice.volume();
}
if (K_iteration == distance)
{
++K_iteration;
}
H_tot = likelyhoods.at(K_iteration);
int S = K_iteration * D;
std::vector<double>::const_iterator it;
int i = 0;
for (it = (coordinates.begin() + S); it != (coordinates.begin() + S + D); ++it)
{
Matrix[i] = *it;
++i;
}
return K_iteration;
}
开发者ID:smcantab,项目名称:mcising,代码行数:33,代码来源:mcising_NestedSampling_get_alternativelikelyhood_coordinates.cpp
示例5: converter
void TransfererRunner::processEdge(Lattice& lattice, Lattice::EdgeDescriptor edge) {
std::cerr << "PROCESSING:";
tmil::FileParsingScriptFactory* scriptFactory = new tmil::FileParsingScriptFactory;
boost::shared_ptr<tmil::Transferer> transferer_;
transferer_.reset(
new tmil::Transferer(
scriptFactory,
lattice.getAnnotationItemManager().getZObjectsHolderPtr(),
lattice.getAnnotationItemManager().getSymbolFactory()));
transferer_->include(rulesFile_.string().c_str());
EdgeToZsyntreeConverter converter(lattice);
zsyntree* tree = converter.convertEdgeToZsyntree(edge);
std::cerr << " GOT SOURCE:" << tree->zsyntree_to_string() << std::endl;
zsyntree* targetTree = transferer_->doTranslate(tree, NULL, NULL);
std::cerr << " GOT TARGET:" << targetTree->zsyntree_to_string() << std::endl;
putZsyntreeIntoLattice(
lattice,
lattice.getLayerTagManager().createTagCollection(tags_),
targetTree);
putTargetForms_(
lattice,
targetTree,
transferer_);
}
示例6: get_maxlikelyhood_coordinates
int get_maxlikelyhood_coordinates(float* Matrix, std::vector<double>& coordinates, std::vector<double>& likelyhoods, Lattice lattice)
{
int D;
if (lattice.get_dimensions() == 2)
{
D = lattice.area();
}
else
{
D = lattice.volume();
}
std::vector<double>::iterator max_likelyhood = std::max_element(likelyhoods.begin(),likelyhoods.end());
int distance = std::distance(likelyhoods.begin(), max_likelyhood);
int S = distance * D;
std::vector<double>::const_iterator it;
int i = 0;
for (it = (coordinates.begin() + S); it != (coordinates.begin() + S + D); ++it)
{
Matrix[i] = *it;
++i;
}
return distance;
}
示例7: matrixmap_2D
void matrixmap_2D(float* Matrix, float** ptrMatrix, Lattice lattice)
{
int M = lattice.get_M();
int N = lattice.get_N();
for(int i = 1; i <= N; i++)
{
for (int j = 1; j <= M; j++)
{
ptrMatrix[ i + j*(N+2) ] = &(Matrix[ (i-1) + (j-1)*N ]);
}
}
for(int k = 1; k <= M; k++)
{
ptrMatrix[k*(N+2)] = &(Matrix[(k*N-1)]);
ptrMatrix[N+1 + k*(N+2)] = &(Matrix[(k-1)*N]);
}
for(int k = 1; k <= N; k++)
{
ptrMatrix[k] = &(Matrix[(M-1)*N + k - 1]);
ptrMatrix[k + (N+2)*(M+1)] = &(Matrix[k-1]);
}
//corners
ptrMatrix[0] = &(Matrix[N*M-1]);
ptrMatrix[N+1] = &(Matrix[N*(M-1)]);
ptrMatrix[(N+2)*(M+1)] = &(Matrix[N-1]);
ptrMatrix[(N+2)*(M+2)-1] = &(Matrix[0]);
}
示例8: chooseNextVariableByRandom
static int chooseNextVariableByRandom (Lattice <T> & lattice, BitSet & allowed)
{
int count = 0;
static bool inited = false;
if (!inited)
{
srand (time (NULL));
inited = true;
}
for (unsigned int i = 0; i < lattice.variables (); i++)
{
if (allowed[i])
count++;
}
if (count == 0)
return -1;
int random = rand () % count;
for (unsigned int i = 0; i < lattice.variables (); i++)
{
if (allowed[i])
{
if (random == 0)
{
return i;
}
random--;
}
}
return -1;
}
示例9: twist_links
// multiply exp( - i Q ) in `mu' direction.
void twist_links(Lattice &lat, const Float Q, const int mu)
{
// multiply su3 links by u1 links
// assumes both are in canonical order!
// link = exp(-i A_mu Q) where Q is the
// quark electric charge or twist angle
int x[4];
Complex cc(cos(Q), -sin(Q));
Matrix temp;
for(x[3]=0; x[3]<GJP.TnodeSites();x[3]++){
for(x[2]=0; x[2]<GJP.ZnodeSites();x[2]++){
for(x[1]=0; x[1]<GJP.YnodeSites();x[1]++){
for(x[0]=0; x[0]<GJP.XnodeSites();x[0]++){
int offset_x = lat.GsiteOffset(x);
// the link matrix at current site, in direction mu:
Matrix *su3_link = lat.GaugeField() + offset_x + mu;
//cTimesVec((float*)&temp, *(float*)phase, *((float*)phase+1),
cTimesVec((IFloat*)&temp, (IFloat)cc.real(), (IFloat)cc.imag(),
(IFloat*)su3_link, 18);
moveMem((IFloat*)su3_link, (IFloat*)&temp, 18);
}
}
}
}
}
示例10:
//From a single initial lattice
Flow::Flow(Lattice& state, bool firstrow) {
cols = state.colSize();
rows = state.rowSize();
if(firstrow) { //if true
system.push_back(state);
}
}
示例11: l
RayGenerator::RayGenerator(const Lattice & l, unsigned char dim): l(l), dim(dim) {
max = l.size() / l.N()(dim);
origin = l.dx()/2;
origin(dim) = 0;
origin += l.bbox().min();
stride = l.N()((dim+2)%3);
}
示例12: checkLatticeSize
//Return true if Lattice size matches up with that dictated by flow file, false otherwise
void Flow::checkLatticeSize(Lattice testlattice) {
if (testlattice.rowSize() != Flow::getRows()) {
throw runtime_error("Row size inequal.\n");
}
if(testlattice.colSize() != Flow::getCols()) {
throw runtime_error("Column size inequal.\n");
}
}
示例13:
//Constructor which creates a cubeArray from a gas, assigning each LatElem dim cubes in each dimension
//Boolean will remove the boundary of gas model
CubeArray::CubeArray(Model* model, int dim, bool boundariesRemoved) {
int stacks = model->timeSize();
int rows = 0;
int cols = 0;
if(stacks > 0) {
rows = model->getLatT(0).rowSize();
cols = model->getLatT(0).colSize();
}
int n = (dim - 1);
int rowsBoolConsider = (boundariesRemoved ? rows - 2 : rows);
int colsBoolConsider = (boundariesRemoved ? cols - 2 : cols);
int newStacks = 2*n + (n-1)*(stacks-2) + (stacks-1);
int newRows = 2*n + (n-1)*(rowsBoolConsider - 2) + (rowsBoolConsider - 1);
int newCols = 2*n + (n-1)*(colsBoolConsider - 2) + (colsBoolConsider - 1);
cubes.resize(newStacks);
for(int i = 0; i < (newStacks); i++) {
cubes[i].resize(newRows);
for(int j = 0; j < (newRows); j++) {
cubes[i][j].resize(newCols);
}
}
for(int i = 0; i < stackSize(); i++) {
for(int j = 0; j < rowSize(); j++) {
for(int k = 0; k < colSize(); k++) {
cubes[i][j][k].setType(CubeElem::Empty);
}
}
}
int stackInd = 0,rowInd,colInd;
int lowerBound = (boundariesRemoved ? 1:0);
int rowsUpperBound = (boundariesRemoved ? rows - 1 : rows);
int colsUpperBound = (boundariesRemoved ? cols - 1 : cols);
for(int k = 0; k < stacks; k++) {
rowInd = 0;
Lattice l = model->getLatT(k);
vector < vector < CubeElem > > stack;
for(int i = lowerBound ; i < rowsUpperBound ; i++) {
colInd = 0;
vector< CubeElem > row;
for(int j = lowerBound; j < colsUpperBound; j++) {
CubeElem::CubeType t = (l.getElement(i,j)->getValue() == 1 ? CubeElem::Full : CubeElem::Empty);
if(t == CubeElem::Full) {
for(int x = 0; x <= n; x++) {
for (int y = 0; y <= n; y++) {
for(int z = 0; z <= n; z++) {
cubes[stackInd+x][rowInd+y][colInd+z].setType(t);
}
}
}
}
colInd += n;
}
rowInd += n;
}
stackInd += n;
}
setCubeNeighbours();
}
示例14: operator
inline void operator() (Lattice& L, IndexList& idx)
{
typedef typename Lattice::element element;
for(int dim = 0; dim < idx.size(); ++dim)
{
sum += L(idx) * L.get_n_left(idx, dim);
sum += L(idx) * L.get_n_right(idx, dim);
}
}
示例15: holder
EdgeToZsyntreeConverter::EdgeToZsyntreeConverter(Lattice& latticeArg)
:lattice(latticeArg),
sym_fac(latticeArg.getAnnotationItemManager().getSymbolFactory()),
holder(latticeArg.getAnnotationItemManager().getZObjectsHolderPtr()),
lexemeTag_(latticeArg.getLayerTagManager().createSingletonTagCollection("lexeme")),
formTag_(latticeArg.getLayerTagManager().createSingletonTagCollection("form")),
parseTerminalTag_(latticeArg.getLayerTagManager().createSingletonTagCollection("parse-terminal")),
equivMask_(lattice.getLayerTagManager().getSingletonMask("bilexicon")) {
}