void print_time_evolution_of_parameters(FILE *out, ffloat norm, ffloat *host_a, ffloat *host_b, int MSIZE,
                                        ffloat host_mu, ffloat host_alpha, ffloat host_E_dc, ffloat host_E_omega,
                                        ffloat host_omega, ffloat *host_av_data, ffloat t)
{
  printf("\n# t=%0.20f norm=%0.20f\n", t, norm);
  ffloat v_dr_inst = 0 ;
  ffloat v_y_inst = 0;
  ffloat m_over_m_x_inst = 0;
  for( int m = 1; m < 2*host_M+2; m++ ) {
    v_dr_inst += nm(host_b,1,m)*host_dPhi;
    v_y_inst  += nm(host_a,0,m)*phi_y(m)*host_dPhi;
    m_over_m_x_inst += nm(host_a,1,m)*host_dPhi;
  }

  ffloat v_dr_multiplier = 2*gsl_sf_bessel_I0(host_mu)*PI*sqrt(host_alpha)/gsl_sf_bessel_In(1, host_mu);
  ffloat v_y_multiplier  = 4*PI*gsl_sf_bessel_I0(host_mu)/gsl_sf_bessel_In(1, host_mu);
  ffloat m_over_multiplier = PI*host_alpha*sqrt(host_alpha);
  v_dr_inst       *= v_dr_multiplier;
  v_y_inst        *= v_y_multiplier;
  m_over_m_x_inst *= m_over_multiplier;

  host_av_data[1] *= v_dr_multiplier;
  host_av_data[2] *= v_y_multiplier;
  host_av_data[3] *= m_over_multiplier;
  host_av_data[4] *= v_dr_multiplier;
  host_av_data[4] /= t;
  host_av_data[5] *= v_dr_multiplier;
  host_av_data[5] /= t;

  fprintf(out, "#E_{dc}                \\tilde{E}_{\\omega}     \\tilde{\\omega}         mu                     v_{dr}/v_{p}         A(\\omega)              NORM     v_{y}/v_{p}    m/m_{x,k}   <v_{dr}/v_{p}>   <v_{y}/v_{p}>    <m/m_{x,k}>  A_{inst}  t    Asin\n");
  fprintf(out, "%0.20f %0.20f %0.20f %0.20f %0.20f %0.20f %0.20f %0.20f %0.20f %0.20f %0.20f %0.20f %0.20f %0.20f %0.20f\n",
          host_E_dc, host_E_omega, host_omega, host_mu, v_dr_inst, host_av_data[4], norm, v_y_inst,
          m_over_m_x_inst, host_av_data[1], host_av_data[2], host_av_data[3], cos(host_omega*t)*v_dr_inst, t, host_av_data[4]);
} // end of print_time_evolution_of_parameters(...)
// Write out distribution function to FILE *out. This used when writing data to generate animation
void print_2d_strobe(FILE *out, int MSIZE, ffloat *host_a0, ffloat *host_a, ffloat *host_b, ffloat host_alpha, ffloat t) {
  ffloat norm = 0;
  ffloat dphi_over_2 = host_dPhi/2.0;
  for( int m = 1; m < host_M+1; m++ ) {
    norm += (nm(host_a,0,m)+nm(host_a,0,m))*dphi_over_2;
  }
  norm *= 2*PI*sqrt(host_alpha);

  int i = 0;
  for( ffloat phi_x = -PI; phi_x < PI; phi_x += 0.01 ) {
    for( int m = 1; m < host_M+2; m++ ) {
      ffloat value = 0;
      for( int n = 0; n < host_N+1; n++ ) {
        value  += nm(host_a,n,m)*cos(n*phi_x) + nm(host_b,n,m)*sin(n*phi_x);
      }
      strobe_values[i] = strobe_values[i] + (value<0?0:value);
      //strobe_values[i] = value<0?0:value;
      fprintf(out, "%0.5f %0.5f %0.20f\n", phi_x, phi_y(m), strobe_values[i]);
      //fprintf(out, "%0.5f %0.5f %0.20f\n", phi_x, phi_y(m), value<0?0:value);
      i++;
    }
  }
  fprintf(out, "# norm=%0.20f\n", norm);
  fprintf(out, "# t=%0.20f\n", t);
  printf("# norm=%0.20f\n", norm);
} // end of print_2d_strobe(...)
Ejemplo n.º 3
0
//This function encodes x == a xor b;
 void BLIFwriter::addXorClause(int x, int a, int b){
	 if(!off){
		output<<".names "<<nm(a)<<" "<<nm(b)<<" "<<nm(x)<<endl;
		output<<sgn(a)<<nsgn(b)<<" 1"<<endl;
		output<<nsgn(a)<<sgn(b)<<" 1"<<endl;
	 }
}
Ejemplo n.º 4
0
//This function encodes x == a ? b:c;
 void BLIFwriter::addChoiceClause(int x, int a, int b, int c){
	 if(!off){
		output<<".names "<<nm(a)<<" "<<nm(b)<<" "<<nm(c)<<" "<<nm(x)<<endl;
		output<<sgn(a)<<sgn(b)<<"- 1"<<endl;
		output<<nsgn(a)<<"-"<<sgn(c)<<" 1"<<endl;
	 }
}
Ejemplo n.º 5
0
//This function encodes x == a;
 void BLIFwriter::addEquateClause(int x, int a){
	if( !solveNegation  ){
		if(!off){
			string t = outvar();
			output<<".names "<<nm(a)<<" "<<nm(x)<<" "<<t<<endl;
			output<<sgn(a)<<nsgn(x)<<" 1"<<endl;
			output<<nsgn(a)<<sgn(x)<<" 1"<<endl;
		}
	}else{
		int tmp = newVar ();
		addXorClause(tmp, x, a);
		finalOr.push_back(tmp);
	}
}
Ejemplo n.º 6
0
    void NotebookApplicationAddin::initialize ()
    {
      IActionManager & am(IActionManager::obj());

      NoteManager & nm(note_manager());

      for(const NoteBase::Ptr & note : nm.get_notes()) {
        note->signal_tag_added.connect(
          sigc::mem_fun(*this, &NotebookApplicationAddin::on_tag_added));
        note->signal_tag_removed.connect(
          sigc::mem_fun(*this, &NotebookApplicationAddin::on_tag_removed));
      }

      nm.signal_note_added.connect(
        sigc::mem_fun(*this, &NotebookApplicationAddin::on_note_added));
      nm.signal_note_deleted.connect(
        sigc::mem_fun(*this, &NotebookApplicationAddin::on_note_deleted));

      am.add_app_action("new-notebook");
      am.get_app_action("new-notebook")->signal_activate().connect(
        sigc::mem_fun(*this, &NotebookApplicationAddin::on_new_notebook_action));
      am.add_app_menu_item(APP_SECTION_NEW, 300, _("New Note_book..."), "app.new-notebook");
        
      m_initialized = true;
    }
Ejemplo n.º 7
0
TEST_F(NMTokenTest, new_nmtoken)
{
  NMToken nm("xs:boolean");

  ASSERT_STREQ("boolean", nm.name());
  ASSERT_STREQ("xs", nm.ns());
}
Ejemplo n.º 8
0
TEST_F(NMTokenTest, new_name_only)
{
  NMToken nm("string");

  ASSERT_STREQ("string", nm.name());
  ASSERT_EQ(nullptr, nm.ns());
}
Ejemplo n.º 9
0
/*!
    Add a series of quads by 'interleaving' \a top and \a bottom.

    This function behaves like quadStrip(), where the odd-numbered vertices in
    the input primitive are from \a top and the even-numbered vertices from
    \a bottom.

    It is trivial to do extrusions using this function:

    \code
    // create a series of quads for an extruded edge along -Y
    addQuadsInterleaved(topEdge, topEdge.translated(QVector3D(0, -1, 0));
    \endcode

    N quad faces are generated where \c{N == min(top.count(), bottom.count() - 1}.
    If \a top or \a bottom has less than 2 elements, this functions does
    nothing.

    Each face is formed by the \c{i'th} and \c{(i + 1)'th}
    vertices of \a bottom, followed by the \c{(i + 1)'th} and \c{i'th}
    vertices of \a top.

    If the vertices in \a top and \a bottom are the perimeter vertices of
    two polygons then this function can be used to generate quads which form
    the sides of a \l{http://en.wikipedia.org/wiki/Prism_(geometry)}{prism}
    with the polygons as the prisms top and bottom end-faces.

    \image quad-extrude.png

    In the diagram above, the \a top is shown in orange, and the \a bottom in
    dark yellow.  The first generated quad, (a, b, c, d) is generated in
    the order shown by the blue arrow.

    To create such a extruded prismatic solid, complete with top and bottom cap
    polygons, given just the top edge do this:
    \code
    QGeometryData top = buildTopEdge();
    QGeometryData bottom = top.translated(QVector3D(0, 0, -1));
    builder.addQuadsInterleaved(top, bottom);
    builder.addTriangulatedFace(top);
    builder.addTriangulatedFace(bottom.reversed());
    \endcode
    The \a bottom QGeometryData must be \b{reversed} so that the correct
    winding for an outward facing polygon is obtained.
*/
void QGLBuilder::addQuadsInterleaved(const QGeometryData &top,
                                     const QGeometryData &bottom)
{
    if (top.count() < 2 || bottom.count() < 2)
        return;
    QGeometryData zipped = bottom.interleavedWith(top);
    bool calcNormal = !zipped.hasField(QGL::Normal);
    if (calcNormal)
    {
        QVector3DArray nm(zipped.count());
        zipped.appendNormalArray(nm);
    }
    bool skip = false;
    QVector3D norm;
    int k = 0;
    for (int i = 0; i < zipped.count() - 2; i += 2)
    {
        if (calcNormal)
            skip = qCalculateNormal(i, i+2, i+3, zipped, &norm);
        if (!skip)
            dptr->addTriangle(i, i+2, i+3, zipped, k);
        if (skip)
            skip = qCalculateNormal(i, i+3, i+1, zipped, &norm);
        if (!skip)
        {
            if (calcNormal)
                setNormals(i, i+3, i+1, zipped, norm);
            dptr->addTriangle(i, i+3, i+1, zipped, k);
        }
    }
    dptr->currentNode->setCount(dptr->currentNode->count() + k);
}
Ejemplo n.º 10
0
/*!
    Adds to this section a set of quads defined by \a strip.

    If \a strip has less than four vertices this function exits without
    doing anything.

    The first quad is formed from the 0'th, 2'nd, 3'rd and 1'st vertices.
    The second quad is formed from the 2'nd, 4'th, 5'th and 3'rd vertices,
    and so on, as shown in this diagram:

    \image quads.png

    One normal per quad is calculated if \a strip does not have normals.
    For this reason quads should have all four vertices in the same plane.
    If the vertices do not lie in the same plane, use addTriangles() instead.

    Since internally \l{geometry-building}{quads are stored as two triangles},
    each quad is actually divided in half into two triangles.

    Degenerate triangles are skipped in the same way as addTriangles().

    \sa addQuads(), addTriangleStrip()
*/
void QGLBuilder::addQuadStrip(const QGeometryData &strip)
{
    if (strip.count() < 4)
        return;
    QGeometryData s = strip;
    bool calcNormal = !s.hasField(QGL::Normal);
    if (calcNormal)
    {
        QVector3DArray nm(s.count());
        s.appendNormalArray(nm);
    }
    bool skip = false;
    QVector3D norm;
    int k = 0;
    for (int i = 0; i < s.count() - 3; i += 2)
    {
        if (calcNormal)
            skip = qCalculateNormal(i, i+2, i+3, s, &norm);
        if (!skip)
            dptr->addTriangle(i, i+2, i+3, s, k);
        if (skip)
            skip = qCalculateNormal(i, i+3, i+1, s, &norm);
        if (!skip)
        {
            if (calcNormal)
                setNormals(i, i+3, i+1, s, norm);
            dptr->addTriangle(i, i+3, i+1, s, k);
        }
    }
    dptr->currentNode->setCount(dptr->currentNode->count() + k);
}
Ejemplo n.º 11
0
/*!
    Adds to this section a set of connected triangles defined by \a strip.

    N triangular faces are generated, where \c{N == strip.count() - 2}.
    The triangles are generated from vertices 0, 1, & 2, then 2, 1 & 3,
    then 2, 3 & 4, and so on.  In other words every second triangle has
    the first and second vertices switched, as a new triangle is generated
    from each successive set of three vertices.

    If \a strip has less than three vertices this function exits without
    doing anything.

    Normals are calculated as for addTriangle(), given the above ordering.

    This function is very similar to the OpenGL mode GL_TRIANGLE_STRIP.  It
    generates triangles along a strip whose two sides are the even and odd
    vertices.

    \sa addTriangulatedFace()
*/
void QGLBuilder::addTriangleStrip(const QGeometryData &strip)
{
    if (strip.count() < 3)
        return;
    QGeometryData s = strip;
    bool calcNormal = !s.hasField(QGL::Normal);
    if (calcNormal)
    {
        QVector3DArray nm(s.count());
        s.appendNormalArray(nm);
    }
    bool skip = false;
    int k = 0;
    for (int i = 0; i < s.count() - 2; ++i)
    {
        if (i % 2)
        {
            if (calcNormal)
                skip = qCalculateNormal(i+1, i, i+2, s);
            if (!skip)
                dptr->addTriangle(i+1, i, i+2, s, k);
        }
        else
        {
            if (calcNormal)
                skip = qCalculateNormal(i, i+1, i+2, s);
            if (!skip)
                dptr->addTriangle(i, i+1, i+2, s, k);
        }
    }
    dptr->currentNode->setCount(dptr->currentNode->count() + k);
}
Ejemplo n.º 12
0
/*!
    Add \a quads - a series of one or more quads - to this builder.

    If \a quads has less than four vertices this function exits without
    doing anything.

    One normal per quad is calculated if \a quads does not have normals.
    For this reason quads should have all four vertices in the same plane.
    If the vertices do not lie in the same plane, use addTriangleStrip()
    to add two adjacent triangles instead.

    Since internally \l{geometry-building}{quads are stored as two triangles},
    each quad is actually divided in half into two triangles.

    Degenerate triangles are skipped in the same way as addTriangles().

    \sa addTriangles(), addTriangleStrip()
*/
void QGLBuilder::addQuads(const QGeometryData &quads)
{
    if (quads.count() < 4)
        return;
    QGeometryData q = quads;
    bool calcNormal = !q.hasField(QGL::Normal);
    if (calcNormal)
    {
        QVector3DArray nm(q.count());
        q.appendNormalArray(nm);
    }
    bool skip = false;
    int k = 0;
    QVector3D norm;
    for (int i = 0; i < q.count(); i += 4)
    {
        if (calcNormal)
            skip = qCalculateNormal(i, i+1, i+2, q, &norm);
        if (!skip)
            dptr->addTriangle(i, i+1, i+2, q, k);
        if (skip)
            skip = qCalculateNormal(i, i+2, i+3, q, &norm);
        if (!skip)
        {
            if (calcNormal)
                setNormals(i, i+2, i+3, q, norm);
            dptr->addTriangle(i, i+2, i+3, q, k);
        }
    }
    dptr->currentNode->setCount(dptr->currentNode->count() + k);
}
Ejemplo n.º 13
0
/*!
    Add \a triangles - a series of one or more triangles - to this builder.

    The data is broken into groups of 3 vertices, each processed as a triangle.

    If \a triangles has less than 3 vertices this function exits without
    doing anything.  Any vertices at the end of the list under a multiple
    of 3 are ignored.

    If no normals are supplied in \a triangles, a normal is calculated; as
    the cross-product \c{(b - a) x (c - a)}, for each group of 3
    logical vertices \c{a(triangle, i), b(triangle, i+1), c(triangle, i+2)}.

    In the case of a degenerate triangle, where the cross-product is null,
    that triangle is skipped.  Supplying normals suppresses this behaviour
    (and means any degenerate triangles will be added to the geometry).

    \b{Raw Triangle Mode}

    If \a triangles has indices specified then no processing of any kind is
    done and all the geometry is simply dumped in to the builder.

    This \b{raw triangle} mode is for advanced use, and it is assumed that
    the user knows what they are doing, in particular that the indices
    supplied are correct, and normals are supplied and correct.

    Normals are not calculated in raw triangle mode, and skipping of null
    triangles is likewise not performed.  See the section on
    \l{raw-triangle-mode}{raw triangle mode}
    in the class documentation above.

    \sa addQuads(), operator>>()
*/
void QGLBuilder::addTriangles(const QGeometryData &triangles)
{
    if (triangles.count() < 3)
        return;
    if (triangles.indexCount() > 0)
    {
        // raw triangle mode
        if (dptr->currentSection == 0)
            newSection();
        dptr->currentSection->appendGeometry(triangles);
        dptr->currentSection->appendIndices(triangles.indices());
        dptr->currentNode->setCount(dptr->currentNode->count() + triangles.indexCount());
    }
    else
    {
        QGeometryData t = triangles;
        bool calcNormal = !t.hasField(QGL::Normal);
        if (calcNormal)
        {
            QVector3DArray nm(t.count());
            t.appendNormalArray(nm);
        }
        bool skip = false;
        int k = 0;
        for (int i = 0; i < t.count() - 2; i += 3)
        {
            if (calcNormal)
                skip = qCalculateNormal(i, i+1, i+2, t);
            if (!skip)
                dptr->addTriangle(i, i+1, i+2, t, k);
        }
        dptr->currentNode->setCount(dptr->currentNode->count() + k);
    }
}
Ejemplo n.º 14
0
os::Dir os::FileSys::readDir(Path d)
{
    os::Dir r;

    DIR * dir = opendir(d.str().c_str());

    if ( !dir ) return r;

    struct dirent * de;

    while ( (de = readdir(dir)) )
    {

        struct stat st;
        std::string nm(de->d_name);

        if ( nm == "." || nm == ".." ) continue;

        string fnm = (d + nm).str();

        if ( -1 == stat(fnm.c_str(), &st) ) continue;

        gl::intint sz =  st.st_size;

        if ( S_ISDIR(st.st_mode) )
            r.dirs.push_back(nm);
        else
            r.files.push_back(std::pair<string, gl::intint>(nm, sz));
    }

    closedir(dir);

    return r;

}
Ejemplo n.º 15
0
void
LIBeam3dNL :: giveInternalForcesVector(FloatArray &answer, TimeStep *tStep, int useUpdatedGpRecord)
{
    GaussPoint *gp = this->giveDefaultIntegrationRulePtr()->getIntegrationPoint(0);
    FloatArray nm(6), stress, strain;
    FloatMatrix x;
    double s1, s2;

    // update temp triad
    this->updateTempTriad(tStep);

    if ( useUpdatedGpRecord == 1 ) {
        stress = static_cast< StructuralMaterialStatus * >( gp->giveMaterialStatus() )->giveStrainVector();
    } else {
        this->computeStrainVector(strain, gp, tStep);
        this->computeStressVector(stress, strain, gp, tStep);
    }

    for ( int i = 1; i <= 3; i++ ) {
        s1 = s2 = 0.0;
        for ( int j = 1; j <= 3; j++ ) {
            s1 += tempTc.at(i, j) * stress.at(j);
            s2 += tempTc.at(i, j) * stress.at(j + 3);
        }

        nm.at(i)   = s1;
        nm.at(i + 3) = s2;
    }

    this->computeXMtrx(x, tStep);
    answer.beProductOf(x, nm);
}
Ejemplo n.º 16
0
/*==============================================================================
 * FUNCTION:		ProcTest::testName
 * OVERVIEW:		Test setting and reading name, constructor, native address
 *============================================================================*/
void ProcTest::testName ()
{
  Prog* prog = new Prog();
  BinaryFile *pBF = new BinaryFileStub();
  CPPUNIT_ASSERT(pBF != 0);
  std::string nm("default name");
  BinaryFileFactory bff;
  pBF = bff.Load(HELLO_PENTIUM);
  FrontEnd *pFE = new PentiumFrontEnd(pBF, prog, &bff);
  CPPUNIT_ASSERT(pFE != 0);
  prog->setFrontEnd(pFE);
  CPPUNIT_ASSERT(prog);
  pFE->readLibraryCatalog();				// Since we are not decoding
  m_proc = new UserProc(prog, nm, 20000); // Will print in decimal if error
  std::string actual(m_proc->getName());
  CPPUNIT_ASSERT_EQUAL(std::string("default name"), actual);

  std::string name("printf");
  LibProc lp(prog, name, 30000);
  actual =  lp.getName();
  CPPUNIT_ASSERT_EQUAL(name, actual);

  ADDRESS a = lp.getNativeAddress();
  ADDRESS expected = 30000;
  CPPUNIT_ASSERT_EQUAL(expected, a);
  a = m_proc->getNativeAddress();
  expected = 20000;
  CPPUNIT_ASSERT_EQUAL(expected, a);

  delete prog;
  delete m_proc;
  // delete pFE;		// No! Deleting the prog deletes the pFE already (which deletes the BinaryFileFactory)
}
Ejemplo n.º 17
0
/*!
    Creates a service instance called \a name. The \a argc and \a argv
    parameters are parsed after the exec() function has been
    called. Then they are passed to the application's constructor.
    The application type is determined by the QtService subclass.

    The service is neither installed nor started. The name must not
    contain any backslashes or be longer than 255 characters. In
    addition, the name must be unique in the system's service
    database.

    \sa exec(), start(), QtServiceController::install()
*/
QtService::QtService(const std::map<QString, QVariant>& args, const QString &name)
{
#if defined(QtService_DEBUG)
    qInstallMsgHandler(QtServiceLogDebug);
    qAddPostRoutine(QtServiceCloseDebugLog);
#endif

    Q_ASSERT(!QtServiceBasePrivate::instance);
    QtServiceBasePrivate::instance = this;

    QString nm(name);
    if (nm.length() > 255) {
    qWarning("QtService: 'name' is longer than 255 characters.");
	nm.truncate(255);
    }
    if (nm.contains('\\')) {
    qWarning("QtService: 'name' contains backslashes '\\'.");
	nm.replace((QChar)'\\', (QChar)'\0');
    }

    d_ptr = new QtServiceBasePrivate(nm);
    d_ptr->q_ptr = this;

    d_ptr->serviceFlags = 0;
    d_ptr->sysd = 0;
    d_ptr->args = args;
}
Ejemplo n.º 18
0
bool CArcModule::lst_dll( const arcname& aname, aflArray& files, const char* wild )
{
	if( !m_dll )
		return false;
	kiPath nm(aname.basedir); nm+=aname.lname;
	HANDLE h = m_dll->openArc( app()->mainhwnd(), nm, M_CHECK_FILENAME_ONLY|M_ERROR_MESSAGE_OFF );
	if( !h ) return false;

	int ct=0;
	files.forcelen( 1 );
	if( 0==m_dll->findfirst( h, wild, &files[0].inf ) )
	{
		do
		{
			INDIVIDUALINFO& iii = files[ct].inf;
			files[ct].isfile =
				 ( *files[ct].inf.szAttribute!='d'
				&& !kiPath::endwithyen(files[ct].inf.szFileName)
				&& !(m_dll->getAttr( h )&FILE_ATTRIBUTE_DIRECTORY) );
			files.forcelen( 1+(++ct) );
		} while( 0==m_dll->findnext( h, &files[ct].inf ) );
	}
	files.forcelen( ct );

	m_dll->closeArc( h );
	return true;
}
Ejemplo n.º 19
0
void sc_clock::register_port( sc_port_base& port, const char* if_typename_ )
{
    std::string nm( if_typename_ );
    if( nm == typeid( sc_signal_inout_if<bool> ).name() ) {
	    SC_REPORT_ERROR(SC_ID_ATTEMPT_TO_BIND_CLOCK_TO_OUTPUT_, "");
    }
}
Ejemplo n.º 20
0
 int32_t MappingCharFilter::read()
 {
     while (true)
     {
         if (charPointer < (int32_t)replacement.length())
             return (int32_t)replacement[charPointer++];
         
         int32_t firstChar = nextChar();
         if (firstChar == -1)
             return -1;
         NormalizeCharMapPtr nm(normMap->submap ? normMap->submap.get((wchar_t)firstChar) : NormalizeCharMapPtr());
         if (!nm)
             return firstChar;
         NormalizeCharMapPtr result(match(nm));
         if (!result)
             return firstChar;
         replacement = result->normStr;
         charPointer = 0;
         if (result->diff != 0)
         {
             int32_t prevCumulativeDiff = getLastCumulativeDiff();
             if (result->diff < 0)
             {
                 for (int32_t i = 0; i < -result->diff; ++i)
                     addOffCorrectMap(nextCharCounter + i - prevCumulativeDiff, prevCumulativeDiff - 1 - i);
             }
             else
                 addOffCorrectMap(nextCharCounter - result->diff - prevCumulativeDiff, prevCumulativeDiff + result->diff);
         }
         
     }
 }
Ejemplo n.º 21
0
void BLIFwriter::hardAssertVarClause(int x){
	if(!off){
		string t = outvar();
		output<<".names "<<nm(x)<<" "<<t<<endl;
		output<<sgn(x)<<" 1"<<endl;		
	}
}
Ejemplo n.º 22
0
 int BLIFwriter::solve(){
 	if(solveNegation){
		if(finalOr.size() > 0){
			vector<int> tmp;
			tmp.resize(finalOr.size() + 1);
			tmp[0] = newVar();
			for(int i=0; i<finalOr.size(); ++i){
				tmp[i+1] = finalOr[i];
			}
			addBigOrClause(&tmp[0], tmp.size()-1);
			output<<".names "<<nm(tmp[0])<<" OUT"<<endl;
			output<<"1 1"<<endl;
		}else{
			output<<".names ";
			for(int i=0; i<tmpID; ++i){
				output<<"tmp"<<i<<" ";
			}
			output<<" OUT"<<endl;
			for(int i=0; i<tmpID; ++i){
				output<<"1";
			}
			output<<" 1"<<endl;
		}
 	}
	output<<".end"<<endl;
	return SATSolver::UNDETERMINED;
}
Ejemplo n.º 23
0
void
LIBeam3dNL :: giveInternalForcesVector(FloatArray &answer, TimeStep *tStep, int useUpdatedGpRecord)
{
    int i, j;
    Material *mat = this->giveMaterial();
    IntegrationRule *iRule = integrationRulesArray [ giveDefaultIntegrationRule() ];
    GaussPoint *gp = iRule->getIntegrationPoint(0);
    FloatArray nm(6), TotalStressVector(6);
    FloatMatrix x;
    double s1, s2;

    // update temp triad
    this->updateTempTriad(tStep);

    if ( useUpdatedGpRecord == 1 ) {
        TotalStressVector = ( ( StructuralMaterialStatus * ) mat->giveStatus(gp) )
                            ->giveStressVector();
    } else {
        this->computeStressVector(TotalStressVector, gp, tStep);
    }

    for ( i = 1; i <= 3; i++ ) {
        s1 = s2 = 0.0;
        for ( j = 1; j <= 3; j++ ) {
            s1 += tempTc.at(i, j) * TotalStressVector.at(j);
            s2 += tempTc.at(i, j) * TotalStressVector.at(j + 3);
        }

        nm.at(i)   = s1;
        nm.at(i + 3) = s2;
    }

    this->computeXMtrx(x, tStep);
    answer.beProductOf(x, nm);
}
ffloat eval_norm(ffloat *host_a, ffloat host_alpha, int MSIZE) {
  ffloat norm = 0;
  for( int m = 1; m < 2*host_M+2; m++ ) {
    norm += nm(host_a,0,m)*host_dPhi;
  }
  norm *= 2*PI*sqrt(host_alpha);
  return norm;
} // end of eval_norm(...)
Ejemplo n.º 25
0
Matrix Matrix::T() const{ //transpose
    Matrix nm(cols, rows);
    for(size_t r = 0; r < rows; r++){
        for(size_t c = 0; c < cols; c++){
            nm.set(c, r, get(r,c));
        }
    }
    return nm;
}
Ejemplo n.º 26
0
void GatewayStack::Start()
{
	WHartAddress nm(NetworkManager_UniqueID());

	StartNMSession(config.NetworkManagerHost(), config.NetworkManagerPort(), config.m_nNmClientListenPort );

	StartAPsServer(config.ListenAccessPointPort(), config.AccessPointClientMinPort(), config.AccessPointClientMaxPort());
	service->Run();
}
QString DataSet::sanitizeName(const QString& name) {
    // remove units
    // slash cannot be in dataset name,
    // because it means subdataset, see
    // python class DataSetModel.setmMesh()
    // see #132
    QString nm(name);
    return nm.replace(QRegExp("\\[.+\\/.+\\]"), "").replace("/", "");
}
Ejemplo n.º 28
0
static PyObject *PyStorage_View(PyStorage *o, PyObject *_args) {
  try {
    PWOSequence args(_args);
    PWOString nm(args[0]);
    return new PyView(o->View(nm), o);
  } catch (...) {
    return 0;
  }
}
Ejemplo n.º 29
0
void mpz_matrix_manager::tensor_product(mpz_matrix const & A, mpz_matrix const & B, mpz_matrix & C) {
    scoped_mpz_matrix CC(*this);
    mk(A.m * B.m, A.n * B.n, CC);
    for (unsigned i = 0; i < CC.m(); i++)
        for (unsigned j = 0; j < CC.n(); j++)
            nm().mul(A(i / B.m, j / B.n), 
                     B(i % B.m, j % B.n), 
                     CC(i, j));
    C.swap(CC);
}
Ejemplo n.º 30
0
/**
 * You should use this function instead of calling scale() directly
 * to keep track of the zoom factor.
 * @param zoom new zoom factor
 */
void CanvasView::setZoom(int zoom)
{
	Q_ASSERT(zoom>0);
	_zoom = zoom;
	QMatrix nm(1,0,0,1, matrix().dx(), matrix().dy());
	nm.scale(_zoom/100.0, _zoom/100.0);
	nm.rotate(_rotate);
	setMatrix(nm);
	emit viewTransformed(_zoom, _rotate);
}