Exemple #1
0
void ASENSOR::ConvertValues( double volts[], matrix &values )
{
matrix V;

    VoltsDoubleToColumnVector(volts,V);
    SampleVolts(V);
    CurrentValues(values);
}
 // This returns the eigenvalues of the matrix, using the values for the
 // Lagrangian parameters from the last call of UpdateForFixedScale and the
 // values for the fields found in fieldConfiguration.
 template< typename ElementType > inline std::vector< double >
 MassesSquaredFromMatrix< ElementType >::MassesSquared(
                       std::vector< double > const& fieldConfiguration ) const
 {
   Eigen::SelfAdjointEigenSolver< EigenMatrix >
   eigenvalueFinder( CurrentValues( fieldConfiguration ),
                     Eigen::EigenvaluesOnly );
   std::vector< double > massesSquared( numberOfRows );
   for( size_t rowIndex( 0 );
        rowIndex < numberOfRows;
        ++rowIndex )
   {
     massesSquared[ rowIndex ] = eigenvalueFinder.eigenvalues()( rowIndex );
   }
   return massesSquared;
 }
Exemple #3
0
void CStateTemplate::reorder(const CVector< CModelEntity * > & entitiesX)
{
  assert(entitiesX.size() + 1 == mIndexMap.size());

  // Update mpEntities to reflect the new order;

  memcpy(mpEntities + 1, entitiesX.array(), sizeof(CModelEntity *) * entitiesX.size());
  mInsert = entitiesX.size() + 1;

  std::map< CModelEntity *, unsigned C_INT32 >::iterator found;
  CVector<C_FLOAT64> InitialValues(entitiesX.size());
  CVector<C_FLOAT64> CurrentValues(entitiesX.size());

  CModelEntity *const*it = entitiesX.array();
  CModelEntity *const*end = it + entitiesX.size();

  unsigned C_INT32 i;
  unsigned C_INT32 Independent, Dependent, Fixed;
  Independent = Dependent = Fixed = 0;

  for (i = 1; it != end; ++it, i++)
    {
      found = mIndexMap.find(*it);
      assert(found != mIndexMap.end());

      // Build new order
      InitialValues[i - 1] = *(mpInitialValues + found->second);
      CurrentValues[i - 1] = *(mpCurrentValues + found->second);

      // Update pointer if necessary
      if (i != found->second)
        {
          found->second = i;
          found->first->setInitialValuePtr(mpInitialValues + found->second);
          found->first->setValuePtr(mpCurrentValues + found->second);
        }

      // Count numbers for each status type;
      if ((*it)->isUsed())
        switch ((*it)->getStatus())
          {
            case CModelEntity::FIXED:
              Fixed++;
              break;

            case CModelEntity::REACTIONS:

              if (static_cast< CMetab * >(*it)->isDependent())
                {
                  assert(Fixed == 0);
                  Dependent++;
                }
              else
                {
                  assert(Dependent == 0);
                  Independent++;
                }

              break;

            case CModelEntity::ODE:
              assert(Dependent == 0);
              Independent++;
              break;

            case CModelEntity::ASSIGNMENT:
              assert(Fixed == 0);
              Dependent++;
              break;

            case CModelEntity::TIME:
              assert(false);
              break;
          }
      else
        Fixed++;
    }

  mpBeginIndependent = mpEntities + 1;
  mpBeginDependent = mpBeginIndependent + Independent;
  mpBeginFixed = mpBeginDependent + Dependent;
  mpEnd = mpBeginFixed + Fixed;

  memcpy(mpInitialValues + 1, InitialValues.array(), sizeof(C_FLOAT64) * entitiesX.size());
  memcpy(mpCurrentValues + 1, CurrentValues.array(), sizeof(C_FLOAT64) * entitiesX.size());

  // Update the iterators of the states
  mInitialState.updateIterator(Independent, Dependent, Fixed);
  mCurrentState.updateIterator(Independent, Dependent, Fixed);
}