/**
 *generateV - calculates the sum of the squared error for all variables
 *
 *  @param a            the parameters to calculate V
 *  @param Vds          the variables to calculate V
 *  @param Vgd          the varaibles to calculate V
 *  @param S_measured   the measured S values
 *  @param paramSize    number of parameter elements
 *  @param measSize     number of measurements of S
 *  @param task         for different task in program assignment
 *                          3 --> S_model = Id
 *                          4 --> S_model = Id / Id_meas
 *                          5 --> S_model = log10(Id)
 *  @return             the squared error
 */
double generateV(double *a, double *Vds, double *Vgs, double *S_measured,
                 int paramSize, int measSize, int task)
{
  double V = 0;

  if(task == 3)
  {
    for(int i = 0; i < measSize; i++)
    {
      //Vgs, Vds, Is, k, Vth
      V += pow(generateId(Vgs[i], Vds[i], a[0], a[1], a[2]) - S_measured[i], 2.0);
    }
  }
  else if(task == 4)
  {
    for(int i = 0; i < measSize; i++)
    {
      //Vgs, Vds, Is, k, Vth
      V += pow(generateId(Vgs[i], Vds[i], a[0], a[1], a[2])/S_measured[i] - 1, 2.0);
    }
  }
  else if(task == 5)
  {
    for(int i = 0; i < measSize; i++)
    {
      //Vgs, Vds, Is, k, Vth
      V += pow(log10(generateId(Vgs[i], Vds[i], a[0], a[1], a[2])) 
                - log10(S_measured[i]), 2.0);
      //if(generateId(Vgs[i], Vds[i], a[0], a[1], a[2]) <= 0)
      //  cout << "asdfasdfasdf " << endl;
    }
  }
  return V;
}
FramebufferObject::FramebufferObject()
  : id_(0)
  , numColorAttachments_(0)
{
    memset(attachments_, 0, sizeof(Texture*) * (CGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS+2));
    generateId();
}
Esempio n. 3
0
TAbscissa::TAbscissa(const Element & ele)
: TBisector(ele)
{
    id = generateId();

    ComputeLength();
}
Esempio n. 4
0
bool RemovableBackend::plug(const QString &devNode, const QString &label)
{
    QString name = generateName(devNode);
    QString id = generateId(devNode);

    if(!m_removableIds.contains(id))
    {
        Medium *medium = new Medium(id, name);
        medium->mountableState(devNode, QString::null, QString::null, false);

        QStringList words = QStringList::split(" ", label);

        QStringList::iterator it = words.begin();
        QStringList::iterator end = words.end();

        QString tmp = (*it).lower();
        tmp[0] = tmp[0].upper();
        QString new_label = tmp;

        ++it;
        for(; it != end; ++it)
        {
            tmp = (*it).lower();
            tmp[0] = tmp[0].upper();
            new_label += " " + tmp;
        }

        medium->setLabel(new_label);
        medium->setMimeType("media/removable_unmounted");

        m_removableIds.append(id);
        return !m_mediaList.addMedium(medium).isNull();
    }
    return false;
}
Esempio n. 5
0
TAbscissa::TAbscissa(const TPoint& PP0, const TPoint& PP1)
: TBisector(PP0, PP1)
{
    id = generateId();

    ComputeLength();
}
ReflectionTypeComponent::ReflectionTypeComponent( const std::string& memberName )
   : m_memberName( memberName )
   , m_isEditable( false )
   , m_canBeSaved( true )
{
   m_id = generateId( memberName );
}
Esempio n. 7
0
bool RemovableBackend::camera(const QString &devNode)
{
    QString id = generateId(devNode);
    if(m_removableIds.contains(id))
    {
        return m_mediaList.changeMediumState(id, QString("camera:/"), false, "media/gphoto2camera");
    }
    return false;
}
Esempio n. 8
0
void Box2dContainer::assignNode(b2Body& body, cocos2d::Node& node)
{
    if (!nodeToId.count(&node)) {
        auto newId = generateId();
        nodeToId[&node] = newId;
        idToNode[newId] = &node;
    }

    body.SetUserData(static_cast<void*>(nodeToId[&node]));
}
Esempio n. 9
0
bool RemovableBackend::unplug(const QString &devNode)
{
    QString id = generateId(devNode);
    if(m_removableIds.contains(id))
    {
        m_removableIds.remove(id);
        return m_mediaList.removeMedium(id);
    }
    return false;
}
Esempio n. 10
0
 void TfStreamServer::addStream(AlServer::GoalHandle gh)
 {
   gh.setAccepted();
   std::string id = generateId();
   _streams[id].reset(new TfStream(_nh, id, _lookup_fun));
   _streams[id]->updateTransforms(gh.getGoal()->transforms);
   AlServer::Result r;
   r.subscription_id = id;
   r.topic = _nh.resolveName(id);
   gh.setSucceeded(r);
 }
Esempio n. 11
0
bool Geometry3D::init(const geom::Data& data, bool calculateAdjacency)
{
	m_boundingBox = data.getBoundingBox();
	m_additionalUVsCount = data.getAdditionalUVsCount();
	m_meshes = data.getMeshes();
	m_verticesCount = data.getVerticesCount();
	m_indicesCount = data.getIndexBuffer().size();
	if (calculateAdjacency)
	{
		m_adjacency = data.calculateAdjacency();
	}

	glGenBuffers(1, &m_vertexBuffer);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);
	glGenVertexArrays(1, &m_vertexArray);
	glBindVertexArray(m_vertexArray);
	for (size_t component = 0; component < data.getVertexComponentsCount(); component++)
	{
		size_t offset = data.getVertexComponentOffset(component);
		size_t componentSize = data.getVertexComponentSize(component);

		// vertex declaration
		glVertexAttribPointer((GLuint)component,
							  (GLuint)(componentSize / sizeof(float)),
							  GL_FLOAT,
							  GL_FALSE,
							  (GLuint)data.getVertexSize(),
							  BUFFER_OFFSET(offset));
		glEnableVertexAttribArray((GLuint)component);
	}
	glBindVertexArray(0);

	// vertex buffer
	glBufferData(GL_ARRAY_BUFFER, data.getVertexBuffer().size(), data.getVertexBuffer().data(), GL_STATIC_DRAW);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	
	// index buffer
	glGenBuffers(1, &m_indexBuffer);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indicesCount * sizeof(unsigned int), data.getIndexBuffer().data(), GL_STATIC_DRAW);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

	if (CHECK_GL_ERROR)
	{
		destroy();
		return false;
	}

	m_isLoaded = true;
	initDestroyable();
	m_id = generateId();

	return m_isLoaded;
}
Esempio n. 12
0
transition::transition(node * n1, node * n2,QString name,QString lastId)
{
    this->n1 = n1;
    this->n2 = n2;
    this->name = new QString(name);
    this->id = new QString(generateId(lastId));
    this->p1 = new QPointF(getP1());
    this->p2 = new QPointF(getP2());

    nodesAreCircles = false;
}
Esempio n. 13
0
void Texture::create(char *name, char *filename, unsigned char relativePath, unsigned int flags,
		unsigned char filter, float anisotropicFilter) {
	strcpy(this->name, name);
	DataBuffer *dataBuffer = new DataBuffer();
	dataBuffer->read(filename, relativePath);
	if (dataBuffer->getSize()) {
		load(dataBuffer);
		generateId(flags, filter, anisotropicFilter);
		freePixel();
		delete dataBuffer;
	}
}
Esempio n. 14
0
TTetrahedron::TTetrahedron() {
    id = generateId();

    A1 = new TAbscissa();
    A2 = new TAbscissa();
    A3 = new TAbscissa();
    A4 = new TAbscissa();
    A5 = new TAbscissa();
    A6 = new TAbscissa();

    volume = 0.0;
}
Esempio n. 15
0
void WButtonGroup::addButton(WRadioButton *button, int id)
{
  Button b;
  b.button = button;
  b.id = id != -1 ? id : generateId();
  buttons_.push_back(b);

  button->setGroup(this);

  if (checkedChangedConnected_)
    button->changed().connect(this, &WButtonGroup::onButtonChange);
}
Esempio n. 16
0
        std::shared_ptr< TimerTask > ExpiryTimerImpl::post(DelayInMillis delay, Callback cb)
        {
            if (delay < 0LL)
            {
                throw InvalidParameterException{ "delay can't be negative." };
            }

            if (!cb)
            {
                throw InvalidParameterException{ "callback is empty." };
            }

            return addTask(convertToTime(Milliseconds{ delay }), std::move(cb), generateId());
        }
Esempio n. 17
0
void RPropertyTypeId::generateId(const std::type_info& classInfo,
        const QString& groupTitle, const QString& title, bool forceNew) {
    if (id!=-1) {
        qWarning() << "RPropertyTypeId::generateId: property already initialized: " << classInfo.name() << ":" << groupTitle << ":" << title;
        return;
    }

    if (getPropertyTypeId(groupTitle, title).isValid() && !forceNew) {
        generateId(classInfo, getPropertyTypeId(groupTitle, title));
        return;
    }

    id = counter++;
    propertyTypeByObjectMap[classInfo.name()].insert(*this);
    titleMap[id].first = groupTitle;
    titleMap[id].second = title;
}
Esempio n. 18
0
TTetrahedron::TTetrahedron() {
	id = generateId();

	/*T1 = new TTriangle();
	T2 = new TTriangle();
	T3 = new TTriangle();
	T4 = new TTriangle();*/

	A1 = new TAbscissa();
	A2 = new TAbscissa();
	A3 = new TAbscissa();
	A4 = new TAbscissa();
	A5 = new TAbscissa();
	A6 = new TAbscissa();

	volume = 0.0;
}
Esempio n. 19
0
//injection
void BooksimCoreInterface::messageIs(SS_Network::Message *msg){
  
 

  msg->Id = generateId();
  msg->SourceTime = parent->now();

  //queue the message to send
  _inBuffer.push_back(msg);
  has_message[this->id()]++;
  booksim_inflight++;
  
  if(!booksim_active){
    booksim_active=true;
    mainbooksima->statusIs(Activity::executing);
  }
  
}
Esempio n. 20
0
/*
 * SystemCodecInfo
 */
SystemCodecInfo::SystemCodecInfo(unsigned avcodecId, const std::string name,
                                 std::string libName,
                                 MediaType mediaType, CodecType codecType,
                                 unsigned bitrate,
                                 unsigned payloadType,
                                 unsigned minQuality,
                                 unsigned maxQuality)
    : id(generateId())
    , avcodecId(avcodecId)
    , name(name)
    , libName(libName)
    , codecType(codecType)
    , mediaType(mediaType)
    , payloadType(payloadType)
    , bitrate(bitrate)
    , minQuality(minQuality)
    , maxQuality(maxQuality)
{}
Esempio n. 21
0
void KXmlCommandAdvancedDlg::slotAddOption()
{
	if (m_view->currentItem())
	{
		TQString	ID = generateId(m_opts);

		DrBase	*opt = new DrStringOption;
		opt->setName(ID);
		opt->set("text", i18n("New Option"));
		m_opts[ID] = opt;

		TQListViewItem	*item = new TQListViewItem(m_view->currentItem(), i18n("New Option"), ID);
		item->setRenameEnabled(0, true);
		item->setPixmap(0, SmallIcon("document"));
		m_view->ensureItemVisible(item);
		item->startRename(0);
	}
}
Esempio n. 22
0
void KXmlCommandAdvancedDlg::slotAddGroup()
{
	if (m_view->currentItem())
	{
		TQString	ID = generateId(m_opts);

		DrGroup	*grp = new DrGroup;
		grp->setName(ID);
		grp->set("text", i18n("New Group"));
		m_opts[ID] = grp;

		TQListViewItem	*item = new TQListViewItem(m_view->currentItem(), i18n("New Group"), ID);
		item->setRenameEnabled(0, true);
		item->setPixmap(0, SmallIcon("folder"));
		m_view->ensureItemVisible(item);
		item->startRename(0);
	}
}
Esempio n. 23
0
    Wagnis::Wagnis(QNetworkAccessManager *manager, const QString &applicationName, const QString applicationVersion, QObject *parent) : QObject(parent)
    {
        qDebug() << "Initializing Wagnis...";
        this->manager = manager;
        this->applicationName = applicationName;
        this->applicationVersion = applicationVersion;
        getIpInfo();

        /* Load the human readable error strings for libcrypto */
        ERR_load_crypto_strings();
        /* Load all digest and cipher algorithms */
        OpenSSL_add_all_algorithms();
        /* Load config file, and other important initialisation */
        OPENSSL_config(NULL);

        generateId();
        readRegistration();

    }
Esempio n. 24
0
void Connection::connectToWorldServer(const char* worldServerName, const char* port)
{
    int serverFd = createWorldServerSocket();

    bindSocket(serverFd, GHOST_PORT);

    addrinfo hints, *addressInfo;
    int status;

    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_INET;
    hints.ai_socktype = SOCK_STREAM;

    if ((status = getaddrinfo(worldServerName, port, &hints, &addressInfo)) != 0)
        error("Error on get server info, %s", gai_strerror(status));

    connect(serverFd, addressInfo->ai_addr, addressInfo->ai_addrlen);

    worldServerSocket = new Socket(generateId(), serverFd, addressInfo);
}
Esempio n. 25
0
TTetrahedron::TTetrahedron(const TPoint& X1, const TPoint& X2,
                           const TPoint& X3, const TPoint& X4) {
    id = generateId();

    this->X1 = X1;
    this->X2 = X2;
    this->X3 = X3;
    this->X4 = X4;

    T1.SetPoints(X2, X3, X4);
    T2.SetPoints(X1, X3, X4);
    T3.SetPoints(X1, X2, X4);
    T4.SetPoints(X1, X2, X3);

    A1 = new TAbscissa(X1, X2);
    A2 = new TAbscissa(X2, X3);
    A3 = new TAbscissa(X3, X1);
    A4 = new TAbscissa(X1, X4);
    A5 = new TAbscissa(X2, X4);
    A6 = new TAbscissa(X3, X4);

    ComputeVolume();
}
Esempio n. 26
0
void RemovableBackend::handleMtabChange()
{
    QStringList new_mtabIds;
    KMountPoint::List mtab = KMountPoint::currentMountPoints();

    KMountPoint::List::iterator it = mtab.begin();
    KMountPoint::List::iterator end = mtab.end();

    for(; it != end; ++it)
    {
        QString dev = (*it)->mountedFrom();
        QString mp = (*it)->mountPoint();
        QString fs = (*it)->mountType();

        QString id = generateId(dev);
        new_mtabIds += id;

        if(!m_mtabIds.contains(id) && m_removableIds.contains(id))
        {
            m_mediaList.changeMediumState(id, dev, mp, fs, true, false, "media/removable_mounted");
        }
    }

    QStringList::iterator it2 = m_mtabIds.begin();
    QStringList::iterator end2 = m_mtabIds.end();

    for(; it2 != end2; ++it2)
    {
        if(!new_mtabIds.contains(*it2) && m_removableIds.contains(*it2))
        {
            m_mediaList.changeMediumState(*it2, false, false, "media/removable_unmounted");
        }
    }

    m_mtabIds = new_mtabIds;
}
Esempio n. 27
0
const string SkinParser::uniqueId( const string &id )
{
    string newId;

    if( m_idSet.find( id ) != m_idSet.end() )
    {
        // The id was already used
        if( id != "none" )
        {
            msg_Warn( getIntf(), "non-unique id: %s", id.c_str() );
        }
        newId = generateId();
    }
    else
    {
        // OK, this is a new id
        newId = id;
    }

    // Add the id to the set
    m_idSet.insert( newId );

    return newId;
}
Esempio n. 28
0
FramebufferObject::FramebufferObject() : _id(0) {
	generateId();
}
Esempio n. 29
0
ofxTransmitter::ofxTransmitter()
	:id(generateId()) {}
Esempio n. 30
0
SipPlugin*
TwitterFactory::createPlugin( const QString& pluginId )
{
    return new TwitterPlugin( pluginId.isEmpty() ? generateId() : pluginId );
}