Esempio n. 1
0
int main( int argc, char **argv ) {
  int size = 256;
  // generate a symmetric, positive definite matrix
  double *M = (double *) malloc( size*size*sizeof(double) );
  fill( M, size*size);  
  double *Afull = (double *) malloc( size*size*sizeof(double) );
  char T = 'T', N = 'n';
  double one = 1., zero = 0.;
  dgemm_( &T, &N, &size, &size, &size, &one, M, &size, M, &size, &zero, Afull, &size );
  double *A = (double *) malloc( size*(size+1)/2*sizeof(double) );
  double *Acopy = (double *) malloc( size*(size+1)/2*sizeof(double) );
  for( int r = 0; r < size; r++ )
    for( int c = 0; c <= r; c++ ) {
      setEntry(A, size, r, c, Afull[r*size+c]);
      setEntry(Acopy, size, r, c, Afull[r*size+c], size);
    }
  //printMatrix(Afull,size);
  double startTime = read_timer();
  chol(A,size);
  double endTime = read_timer();
  printf("Time %f Gflop/s %f\n", endTime-startTime, size*size*size/3./(endTime-startTime)/1.e9); 
  int info = 0;
  char L = 'L';
  startTime = read_timer();
  dpptrf_( &L, &size, Acopy, &info);
  endTime = read_timer();
  printf("dpptrf Time %f Gflop/s %f\n", endTime-startTime, size*size*size/3./(endTime-startTime)/1.e9); 
  printf("info is %d, size is %d\n", info, size );
  startTime = read_timer();
  dpotrf_( &L, &size, Afull, &size, &info);
  endTime = read_timer();
  printf("dpotrf Time %f Gflop/s %f\n", endTime-startTime, size*size*size/3./(endTime-startTime)/1.e9); 
  //printMatrix(Afull,size);

  double maxDev = 0.;
  /*
  for( int r = 0; r < size; r++ )
    for( int c = 0; c <= r; c++ ) {
      maxDev = max(maxDev,fabs(Afull[r*size+c]-getEntry(A,size,r,c)));
      Afull[r*size+c] = getEntry(A,size,r,c);
    }
  */
  for( int r = 0; r < size; r++ )
    for( int c = 0; c < size; c++ ) {
      maxDev = max(maxDev,fabs(getEntry(Acopy,size,r,c,size)-getEntry(A,size,r,c)));
      //      Afull[r*size+c] = getEntry(Acopy,size,r,c,size);
    }
  //printMatrix(Afull,size);
  printf("Max deviation: %f\n", maxDev);
  //for( int r = 0; r < size; r++ )
  //  for( int c = 0; c < size; c++ ) {
  //    Afull[r*size+c] = getEntry(A,size,r,c);
  //  }
  //printMatrix(Afull,size);
  return 0;
}
Esempio n. 2
0
void Matrix::ero_3(int row_1, int row_2)
{
	if(row_1 < 0 || row_1 >= getRow() || row_2 < 0 || row_2 >= getRow())
		throw RowNotFound();
	for(int j = 0; j < getColumn(); j++)
	{
		T temp = getEntry(row_1, j);
		setEntry(row_1, j, getEntry(row_2, j));
		setEntry(row_2, j, temp);
	}
}
Esempio n. 3
0
void Setup_Colors::cancel()
{
    userPalette->rollback();
    int type = userPalette->getColorTypeAt(mSelected);
    const gcn::Color *col = &userPalette->getColor(type);
    mGradTypeSlider->setValue(userPalette->getGradientType(type));
    const int delay = userPalette->getGradientDelay(type);
    setEntry(mGradDelaySlider, mGradDelayText, delay);
    setEntry(mRedSlider, mRedText, col->r);
    setEntry(mGreenSlider, mGreenText, col->g);
    setEntry(mBlueSlider, mBlueText, col->b);
}
Esempio n. 4
0
void Setup_Colors::valueChanged(const gcn::SelectionEvent &event)
{
    mSelected = mColorBox->getSelected();
    int type = userPalette->getColorTypeAt(mSelected);
    const gcn::Color *col = &userPalette->getColor(type);
    Palette::GradientType grad = userPalette->getGradientType(type);
    const int delay = userPalette->getGradientDelay(type);

    mPreview->clearRows();
    mPreviewBox->setContent(mTextPreview);
    mTextPreview->setFont(boldFont);
    mTextPreview->setTextColor(col);
    mTextPreview->setTextBGColor(NULL);
    mTextPreview->setOpaque(false);
    mTextPreview->setShadow(true);
    mTextPreview->setOutline(true);
    mTextPreview->useTextAlpha(false);

    switch (type)
    {
        case UserPalette::PARTICLE:
        case UserPalette::EXP_INFO:
        case UserPalette::PICKUP_INFO:
        case UserPalette::HIT_PLAYER_MONSTER:
        case UserPalette::HIT_MONSTER_PLAYER:
        case UserPalette::HIT_CRITICAL:
        case UserPalette::MISS:
            mTextPreview->setShadow(false);
    }

    if (grad != Palette::STATIC && grad != Palette::PULSE)
    { // If nonstatic color, don't display the current, but the committed
      // color at the sliders
        col = &userPalette->getCommittedColor(type);
    }
    else if (grad == Palette::PULSE)
    {
        col = &userPalette->getTestColor(type);
    }

    setEntry(mGradDelaySlider, mGradDelayText, delay);
    setEntry(mRedSlider, mRedText, col->r);
    setEntry(mGreenSlider, mGreenText, col->g);
    setEntry(mBlueSlider, mBlueText, col->b);

    mGradTypeSlider->setValue(grad);
    updateGradType();
    mGradTypeSlider->setEnabled(true);
}
Esempio n. 5
0
static list_t appendNewFacets(zhull_t * const zh, const size_t num_facets)
{
  facet_t *new_facet;
  index_t i;
  entry_t e0=entry_makeIndex(0);
  list_t new_facets;

  new_facets=initConstantList(e0, num_facets);

  for (i=0; i<getLength(new_facets); i++) {
    new_facet = (facet_t*) malloc(sizeof(facet_t));
    if (new_facet==0) {
      break;
    }
    new_facet->neighbors=emptyList();
    new_facet->corners=emptyList();
    new_facet->outsideset=emptyList();
    new_facet->insideset=emptyList();
    new_facet->maxdistance=0;
    new_facet->farthest_outside_point=0;
    //        printf("%li, %li\n", new_facet, entry_makePointer(new_facet));
    setEntry(new_facets,i,entry_makePointer(new_facet));
    //        printf("created facet %li\n",new_facet);
  }
  appendListToList(&(zh->facets),new_facets);
  return new_facets;
}
Esempio n. 6
0
// ------------------------------------------------------------------
bool
JcnModel::addEntry(JcnCalc & trg,
					JcnCalc & src,
					int f_matchMask,
					int b_matchMask,
					int fb_matchMask					
					)
{
	if (jcndbg)
		std::cout << "JcnModel::addEntry: " << trg.text() << std::endl;

	EntryMap_itr_t itr = _entryMap.find(trg.text());
	if ( itr == _entryMap.end())
	{
		int mask = 0;

		trg.match(src, mask, f_matchMask, b_matchMask, fb_matchMask);

		_entryMap.insert(std::make_pair(trg.text(), trg));
		
		return setEntry(trg);
	}
	else
	{
		return -1;
	}
}
Esempio n. 7
0
House::House(uint32 hId, const std::string &name, const Position &pos)
{
    setId(hId);
    setName(name);
    if(pos.isValid())
        setEntry(pos);
}
Esempio n. 8
0
void Matrix::ero_2(int beg_row, int des_row, const T & scaler)
{
	if(beg_row < 0 || beg_row >= getRow() || des_row < 0 || des_row >= getRow())
		throw RowNotFound();
	for(int j = 0; j < getColumn(); j++)
		setEntry(des_row, j, getEntry(des_row, j) + getEntry(beg_row, j) * scaler);
}
Esempio n. 9
0
/**
 * @brief Calculate the walltime for a job.
 *
 * @param job The job to set the walltime for.
 *
 * @return No return value.
 */
static void setJobWalltime(Job_t *job)
{
    time_t now = time(NULL);
    time_t wspan=0, whour=0, wmin=0, wsec=0;
    char walltime[100];

    if (!job) {
	mlog("%s: invalid job!\n", __func__);
	return;
    }

    if (!job->start_time || job->start_time > now) {
	mlog("%s: walltime calc error\n", __func__);
	return;
    }

    wspan = now - job->start_time;
    job->res.walltime = wspan;

    whour = wspan / 3600;
    wspan = wspan % 3600;
    wmin = wspan / 60;
    wsec = wspan % 60;

    snprintf(walltime, 100, "%02zu:%02zu:%02zu", whour, wmin, wsec);
    setEntry(&job->status.list, "resources_used", "walltime", walltime);
}
Esempio n. 10
0
void ArpCache::receivedArpMine(folly::IPAddressV4 ip,
                               folly::MacAddress mac,
                               PortID port,
                               ArpOpCode op) {
  // always set an entry, even if the reply was unsolicited
  setEntry(ip, mac, port, NeighborEntryState::REACHABLE);
}
Esempio n. 11
0
Board::Board()
{
	for (int row = 0; row < MAX_SIZE; ++row) {
		for (int col = 0; col < MAX_SIZE; ++col) {
			setEntry(row, col, '.');
		}
	}
}
Esempio n. 12
0
bool Settings::set(const std::string &name, const std::string &value)
{
	if (!setEntry(name, &value, false, false))
		return false;

	doCallbacks(name);
	return true;
}
Esempio n. 13
0
House::House(uint32 hId, const std::string &name, const Position &pos)
{
    m_nullTile = TilePtr(new Tile(Position()));
    setId(hId);
    setName(name);
    if(pos.isValid())
        setEntry(pos);
}
EmberStatus emberAfRf4ceMsoIrRfDatabaseOriginatorSet(EmberAfRf4ceMsoKeyCode keyCode,
                                                     const EmberAfRf4ceMsoIrRfDatabaseEntry *entry)
{
  uint8_t index = getEntryIndex(keyCode);
  if (index == 0xFF) {
    return EMBER_NOT_FOUND;
  }
  return setEntry(index, entry);
}
Esempio n. 15
0
/* assumes hold elk */
int
fileSnapshot(File *dst, File *src, u32int epoch, int doarchive)
{
	Entry e, ee;

	/* add link to snapshot */
	if(!getEntry(src->source, &e, 1) || !getEntry(src->msource, &ee, 1))
		return 0;

	e.snap = epoch;
	e.archive = doarchive;
	ee.snap = epoch;
	ee.archive = doarchive;

	if(!setEntry(dst->source, &e) || !setEntry(dst->msource, &ee))
		return 0;
	return 1;
}
Esempio n. 16
0
void bfsFindExit(Maze &M)
{
	queue <Position> Q;
	
	vector<vector<Position> > pred;
	init_table(pred, M.size, NULLPOS);
	Position current, nbr;
	stack<Position> path;
	current = M.start;
	M.visit(current);
	Q.push(current);
	
	while (true)
	{
		/* First condition if the current position is the exit*/
		if (current == M.exitpos)
		{
			cout << endl;
			printPath(pred, current);
			return;

		}
		/* Checking if current is a wall*/
		if (current == NULLPOS)
		{
			cout << "Now way out" << endl;
			return;

		}
		/* Getting the first open neighbor */
		nbr = M.getOpenNeighbor(current);
		/* If neighbor is a wall*/
		if (nbr == NULLPOS)
		{
			Q.pop();
			current = Q.front();
			
			continue;
		}
		/* Otherwise set entry and visit neighbor*/
		else
		{
			setEntry(pred, nbr, current);
			M.visit(nbr);
			current = nbr;
			Q.push(nbr);
		}

		
		

	}
	
	
	system("PAUSE");

}
Esempio n. 17
0
rspfRpfFrameEntry::rspfRpfFrameEntry(const rspfFilename& rootDirectory,
                                       const rspfFilename& pathToFrameFileFromRoot)
   :m_exists(false),
    m_rootDirectory(rootDirectory),
    m_pathToFrameFileFromRoot(pathToFrameFileFromRoot),
    m_fullValidPath()
{
   setEntry(rootDirectory,
            pathToFrameFileFromRoot);
}
Esempio n. 18
0
void collision_detection::AllowedCollisionMatrix::setEntry(const std::string& name, bool allowed)
{
  std::string last = name;
  for (std::map<std::string, std::map<std::string, AllowedCollision::Type> >::iterator it = entries_.begin() ; it != entries_.end() ; ++it)
    if (name != it->first && last != it->first)
    {
      last = it->first;
      setEntry(name, it->first, allowed);
    }
}
Esempio n. 19
0
void Cache::addEntry(const QUrl &url, const QByteArray &data)
{
	Entry entry = getEntry(url);
	entry.md5 = QCryptographicHash::hash(data, QCryptographicHash::Md5);
	entry.updated = QDateTime::currentDateTime();

	FS::write(absoluteFilename(entry), data);

	setEntry(entry);
}
void GuiPreferences::deleteSource(void)
{
  int curIndex = currentSourceIndex();
  if (curIndex >= 0 && curIndex < MAX_SRCS) {
    m_sourceBtns.at(curIndex)->setEnabled(false);
    setSourceState(curIndex, false);
    setEntry(Settings::SRC_BUCKET_KEY, getSourceStatesSerialized());
    sync();
    updateFields();
  }
}
Esempio n. 21
0
 void DataStore::setData(const fzBuffer& data, const char *key)
 {
     fzStoreEntry entry;
     entry.key  = fzStrcpy(key);
     entry.hash = fzHash(key);
     entry.type = kFZData_data;
     
     entry.data = data;
     
     setEntry(entry);
 }
Esempio n. 22
0
 void DataStore::setString(const char* value, const char *key)
 {
     fzStoreEntry entry;
     entry.key  = fzStrcpy(key);
     entry.hash = fzHash(key);
     entry.type = kFZData_string;
     
     entry.data = fzBuffer(fzStrcpy(value), strlen(value)+1);
     
     setEntry(entry);
 }
Esempio n. 23
0
 void DataStore::setInteger(int32_t value, const char *key)
 {
     fzStoreEntry entry;
     entry.key = fzStrcpy(key);
     entry.hash = fzHash(key);
     entry.type = kFZData_integer;
     
     entry.integerValue = value;
     
     setEntry(entry);
 }
Esempio n. 24
0
 void DataStore::setFloat(double value, const char *key)
 {
     fzStoreEntry entry;
     entry.key = fzStrcpy(key);
     entry.hash = fzHash(key);
     entry.type = kFZData_float;
     
     entry.floatValue = value;
     
     setEntry(entry);
 }
EmberStatus emberAfRf4ceMsoIrRfDatabaseOriginatorClear(EmberAfRf4ceMsoKeyCode keyCode)
{
  // Clearing an entry is the same as replacing it with a default.
  EmberAfRf4ceMsoIrRfDatabaseEntry entry;
  uint8_t index = getEntryIndex(keyCode);
  if (index == 0xFF) {
    return EMBER_NOT_FOUND;
  }
  SET_DEFAULT(&entry);
  return setEntry(index, &entry);
}
Esempio n. 26
0
/*!
    Set an array of cells in this colormap. \a count is the number of
    colors that should be set, \a colors is the array of colors, and
    \a base is the starting index.  The first element in \a colors
    is set at \a base in the colormap.
*/
void QGLColormap::setEntries(int count, const QRgb *colors, int base)
{
    detach();
    if (!d->cells)
        d->cells = new QVector<QRgb>(256);

    Q_ASSERT_X(colors && base >= 0 && (base + count) <= d->cells->size(), "QGLColormap::setEntries",
               "preconditions not met");
    for (int i = 0; i < count; ++i)
        setEntry(base + i, colors[i]);
}
Esempio n. 27
0
void Exception::setEntry(Entry &dest, const Entry &src) throw() {
	setEntry(
			dest,
			src.namedErrorCode_,
			src.message_,
			src.stackTrace_,
			src.typeName_,
			src.fileName_,
			src.functionName_,
			src.lineNumber_,
			src.literalFlags_);
}
void emberAfPluginRf4ceMsoIncomingIrRfDatabaseAttributeCallback(uint8_t pairingIndex,
                                                                uint8_t entryIndex,
                                                                uint8_t valueLength,
                                                                const uint8_t *value)
{
  EmberAfRf4ceMsoIrRfDatabaseEntry entry;
  const uint8_t *finger;
  uint8_t index;

  // The entry index is the key code.  If we don't support the key code, we
  // ignore this entry.
  index = getEntryIndex((EmberAfRf4ceMsoKeyCode)entryIndex);
  if (index == 0xFF) {
    return;
  }

  // TODO: Check length of incoming data.

  finger = value;
  entry.flags = *finger++;

  // TODO: Extract RF descriptor parsing to a function.
  if (emberAfRf4ceMsoIrRfDatabaseEntryHasRfPressedDescriptor(&entry)) {
    entry.rfPressedDescriptor.rfConfig = *finger++;
    entry.rfPressedDescriptor.txOptions = *finger++;
    entry.rfPressedDescriptor.payloadLength = *finger++;
    entry.rfPressedDescriptor.payload = finger;
    finger += entry.rfPressedDescriptor.payloadLength;
  }
  if (emberAfRf4ceMsoIrRfDatabaseEntryHasRfRepeatedDescriptor(&entry)) {
    entry.rfRepeatedDescriptor.rfConfig = *finger++;
    entry.rfRepeatedDescriptor.txOptions = *finger++;
    entry.rfRepeatedDescriptor.payloadLength = *finger++;
    entry.rfRepeatedDescriptor.payload = finger;
    finger += entry.rfRepeatedDescriptor.payloadLength;
  }
  if (emberAfRf4ceMsoIrRfDatabaseEntryHasRfReleasedDescriptor(&entry)) {
    entry.rfReleasedDescriptor.rfConfig = *finger++;
    entry.rfReleasedDescriptor.txOptions = *finger++;
    entry.rfReleasedDescriptor.payloadLength = *finger++;
    entry.rfReleasedDescriptor.payload = finger;
    finger += entry.rfReleasedDescriptor.payloadLength;
  }
  if (emberAfRf4ceMsoIrRfDatabaseEntryHasIrDescriptor(&entry)) {
    entry.irDescriptor.irConfig = *finger++;
    entry.irDescriptor.irCodeLength = *finger++;
    entry.irDescriptor.irCode = finger;
    finger += entry.irDescriptor.irCodeLength;
  }

  setEntry(index, &entry);
}
Esempio n. 29
0
void House::load(const TiXmlElement *elem)
{
    std::string name = elem->Attribute("name");
    if(name.empty())
        name = stdext::format("Unnamed house #%lu", getId());

    setName(name);
    setRent(elem->readType<uint32>("rent"));
    setSize(elem->readType<uint32>("size"));
    setTownId(elem->readType<uint32>("townid"));
    m_isGuildHall = elem->readType<bool>("guildhall");
    setEntry(elem->readPos("entry"));
}
Esempio n. 30
0
/**
* @brief Add used memory to the job account information.
*
* @param job The job to add the memory information to.
*
* @param mem The used physical memory to add.
*
* @param vmem The used virtual memory to add.
*
* @return No return value.
*/
static void setJobMemUsage(Job_t *job, uint64_t mem, uint64_t vmem)
{
    char memory[100];

    if (!job) {
	mlog("%s: got invalid job!\n", __func__);
	return;
    }

    mdbg(PSMOM_LOG_ACC, "%s: new_mem:%lu new_vmem:%lu old_mem:%lu "
	    "old_vmem:%lu\n", __func__, mem, vmem, job->res.mem, job->res.vmem);

    if (mem > job->res.mem) {
	job->res.mem = mem;
	snprintf(memory, sizeof(memory), "%" PRIu64 "kb", mem);
	setEntry(&job->status.list, "resources_used", "mem", memory);
    }

    if (vmem > job->res.vmem) {
	job->res.vmem = vmem;
	snprintf(memory, sizeof(memory), "%" PRIu64 "kb", vmem);
	setEntry(&job->status.list, "resources_used", "vmem", memory);
    }
}