Exemplo n.º 1
0
void cofdm_map::set_data(ivec x)
{
cvec qv;
bvec ce;
int K = x.length();
int i;

	ce.set_length(K); ce.ones();
	#if (DEBUG_LEVEL == 3)
	cout << "***** cofdm_map::set_data *****" << endl;	
	cout << "K=" << K << endl;
	cout << "ce=" << ce << endl;
	cout << "x=" << x << endl;
	cout << "data_carriers=" << data_carriers << endl;
	#endif

	if( K == data_carriers.length() ) {
		qv = qammod.process(ce,x);
		#if (DEBUG_LEVEL == 3)
		cout << "qv=" << qv << endl;
		#endif
		for (i=0; i<K; i++) {
			y0(data_carriers(i))=qv(i);
		}
	}
	else {
		throw sci_exception("cofdm_map::set_data - x.size() <> data_carriers.size()=", data_carriers.length());
	}

	#if (DEBUG_LEVEL == 3)
	cout << "y0(piltos)  y0(zeros) migh have rubbish" << endl;
	cout << "y0=" << y0 << endl;
	cout << "+++++ cofdm_map::set_data +++++" << endl;	
	#endif
}
Exemplo n.º 2
0
// QuatRotation
void Quaternion::QuatRotation(Vector& v)
{
	Quaternion  qv(0, v.x, v.y, v.z);
	Quaternion  qm = (*this) * qv * (*this).inverse();

	v.x = qm.x;
	v.y = qm.y;
	v.z = qm.z;  
}
Exemplo n.º 3
0
btVector3 duCharacter::QmV3(const btVector3 & v, const btQuaternion & q)
{
    // transform Vector3 with a given quaternion
    btVector3 qv(q.x(), q.y(), q.z());
    btVector3 uv = qv.cross(v);
    btVector3 uuv = qv.cross(uv);
    uv *= (2.0 * q.w());
    uuv *= 2.0;
    return v + uv + uuv;
}
Exemplo n.º 4
0
Point3F & QuatF::mulP(const Point3F& p, Point3F* r)
{
   QuatF qq;
   QuatF qi = *this;
   QuatF qv( p.x, p.y, p.z, 0.0f);

   qi.inverse();
   qq.mul(qi, qv);
   qv.mul(qq, *this);
   r->set(qv.x, qv.y, qv.z);
   return *r;
}
Exemplo n.º 5
0
Point3F& m_mul( const Point3F &p, const QuatF &q, Point3F *r )
{
   QuatF qq;
   QuatF qi = q;
   QuatF qv( p.x, p.y, p.z, 0.0f);

   qi.inverse();   
   m_mul(qi, qv, &qq );
   m_mul(qq, q, &qv );
   r->set(qv.x, qv.y, qv.z);
   return ( *r );
}
Exemplo n.º 6
0
void Math::QuatRotation(Vec3 & vOut, const Quat & q, const Vec3 & v)
{
    //NVIDIA SDK implementation
    Vec3 uv, uuv;

    Vec3 qv(q.x, q.y, q.z);

    VecCross(uv, qv, v);
    VecCross(uuv, qv, uv);

    uv *= (2.0f * q.w);
    uuv *= 2.0f;

    vOut = v + uv + uuv;
}
Exemplo n.º 7
0
int KDTree::r_count_around_point(int idxin, int correltime, float r2) {
    std::vector<float> qv(dim);  //  query vector

    for (int i=0; i<dim; i++) {
        qv[i] = the_data[idxin][i];
    }
    // copy the query vector.

    {
        KDTreeResultVector result;
        SearchRecord sr(qv, *this, result);
        // construct the search record.
        sr.centeridx = idxin;
        sr.correltime = correltime;
        sr.ballsize = r2;
        sr.nn = 0;
        root->search(sr);
        return(result.size());
    }
}
Exemplo n.º 8
0
void KDTree::n_nearest_around_point(int idxin, int correltime, int nn,
                                    KDTreeResultVector& result) {

    std::vector<float> qv(dim); //  query vector
    result.clear();
    for (int i=0; i<dim; i++) {
        qv[i] = the_data[idxin][i];
    }
    // copy the query vector.

    {
        SearchRecord sr(qv, *this, result);
        // construct the search record.
        sr.centeridx = idxin;
        sr.correltime = correltime;
        sr.nn = nn;
        root->search(sr);
    }

    if (sort_results) sort(result.begin(), result.end());
}
Exemplo n.º 9
0
void print_mcrl2(std::ostream &out, const std::set<XMASComponent *> &components,
                 const XMASState &state) {
  auto types = all_types(components);
  auto qvars = build_queue_vars(components);

  Mcrl2OperatorPrinter printer;
  Operator::set_printer(&printer);

  out << "sort Msg = struct ";

  bool first = true;
  for (const auto &t : types) {
    out << (first ? "" : " | ") << t;
    first = false;
  }

  out << ";" << std::endl << std::endl;

  for (const auto &q : qvars) {
    out << "sort " << type(q) << " = Int -> Msg;" << std::endl;
  }

  out << std::endl;

  out << "map" << std::endl;

  for (const auto &q : qvars) {
    out << "  give_" << name(q) << ": Msg # " << type(q) << " # Int -> "
        << type(q) << ";" << std::endl;

    out << "  take_" << name(q) << ": " << type(q) << " -> " << type(q) << ";"
        << std::endl;

    out << "  shift_" << name(q) << ": " << type(q) << " -> " << type(q) << ";"
        << std::endl;
  }

  out << std::endl << "var" << std::endl;
  out << "  n : Int;" << std::endl;
  out << "  m : Msg;" << std::endl;

  for (const auto &q : qvars) {
    out << "  " << name(q) << " : " << type(q) << ";" << std::endl;
  }

  out << std::endl << "eqn" << std::endl;

  for (const auto &q : qvars) {
    out << "  give_" << name(q) << "(m, " << name(q) << ", n) = " << name(q)
        << "[n -> m];" << std::endl;

    out << "  take_" << name(q) << "(" << name(q) << ") = shift_" << name(q)
        << "(" << name(q) << ");" << std::endl;

    out << "  shift_" << name(q) << "(" << name(q) << ")(n) = " << name(q)
        << "(n+1);" << std::endl;

    out << "  shift_" << name(q) << "(" << name(q) << ")[n -> m] = " << name(q)
        << "[n+1 -> m];" << std::endl;
  }

  out << std::endl << "act" << std::endl;

  auto transitions = compute_transitions(components, true);

  auto ivars = build_input_vars(transitions);

  int i = 0;
  for (auto &t : transitions) {
    out << "  T" << i;
    t.set_id(i++);

    bool first = true;
    for (const auto &o : t.out()) {
      if (enum_type(o.second).size() <= 1) continue;

      out << (first ? ": " : " # ") << "Msg";
      first = false;
    }
    out << ";" << std::endl;
  }

  out << std::endl;

  out << "proc XMAS(";

  first = true;
  for (const auto &q : qvars) {
    out << (first ? "" : ", ") << name(q) << " : " << type(q)
        << ", " << size(q) << " : Int";
    first = false;
  }
  out << ") = " << std::endl;

  first = true;
  for (const auto &t : transitions) {
    out << "  " << (first ? "  " : "+ ") << "(";
    bool first2 = true;
    for (auto q : t.in_queues()) {
      out << (first2 ? "" : " && ") << size(qv(q)) << " != " << q->c;
      first2 = false;
    }

    for (auto q : t.out_queues()) {
      out << (first2 ? "" : " && ") << size(qv(q)) << " != " << 0;
      first2 = false;
    }

    for (auto c : t.conditions()) {
      out << (first2 ? "" : " && ") << c.op;
      first2 = false;
    }

    out << ") -> ";

    first2 = true;
    for (auto pair : t.out()) {
      if (enum_type(pair.second).size() <= 1) continue;

      out << (first2 ? "sum " : ", ") << iv(pair.first).name() << ": Msg";

      first2 = false;
    }

    if (!first2) out << ". ";

    out << "( T" << t.id();

    first2 = true;
    for (auto pair : t.out()) {
      if (enum_type(pair.second).size() <= 1) continue;

      out << (first2 ? "(" : ", ") << iv(pair.first).name();

      first2 = false;
    }
    if (!first2) out << ")";

    out << " . XMAS(";
    first2 = true;
    for (const auto &qvar : qvars) {
      auto inqs = zip(t.in_queues(), t.in_functions());
      auto outqs = t.out_queues();

      // TODO: efficiency
      auto inq_it = std::find_if(
          inqs.begin(), inqs.end(),
          [&](const std::pair<XMASQueue *, const SymbolicFunction &> &pair) {
            return pair.first == qvar.q;
          });

      if (inq_it != inqs.end()) {
        out << (first2 ? "" : ", ") << "give_" << name(qvar) << "("
            << (*inq_it).second.op << ", " << name(qvar) << ", " << size(qvar)
            << "), " << size(qvar) << "+1";
      } else if (std::find_if(outqs.begin(), outqs.end(), [&](XMASQueue *q) {
                   return q == qvar.q;
                 }) != outqs.end()) {
        out << (first2 ? "" : ", ") << "take_" << name(qvar) << "("
            << name(qvar) << "), " << size(qvar) << "-1";
      } else {
        // nothing happens...
        out << (first2 ? "" : ", ") << name(qvar) << ", " << size(qvar);
      }
      first2 = false;
    }

    out << ")";

    out << " )";
    out << std::endl << std::endl;
    first = false;
  }
  out << ";" << std::endl;

  out << "init XMAS(";
  first = true;
  for (auto &qvar : qvars) {
    auto &qstate = state.get_queue(qvar.q);
    out << (first ? "" : ",\n          ") << "(lambda n : Int . "
        << *types.begin() << ")";

    int i = 0;
    for (auto &packet : qstate) {
      // FIXME: that's a lot for one line
      out << "[" << i << "->"
          << dynamic_cast<SymbolicEnumField *>(
                 packet[0].fields.begin()->second.get())->values[0] << "]";
    }

    out << ", " << qstate.size();
    first = false;
  }

  out << ");";

  out << std::endl << std::endl << std::endl;

  out << "mu X(";

  first = true;
  for (const auto &qvar : qvars) {
    out << (first ? "" : ", ") << size(qvar) << ":Int = " << state.get_queue(qvar.q).size();
    first = false;
  }

  out << ")" << std::endl << " . (" << std::endl;
  out << "      ";
  first = true;
  for (const auto &qvar : qvars) {
    out << (first ? "(" : " && ") << "val(" << size(qvar) << " == 0)";
    first = false;
  }
  out << ")" << std::endl << "   || (";
  first = true;
  for (const auto &qvar : qvars) {
    out << (first ? "(" : " || ") << "val(" << size(qvar) << " != 0)";
    first = false;
  }
  out << ")" << std::endl << "      && (" << std::endl;

  first = true;
  for (const auto &t : transitions) {
    out << "      " << (first ? "   " : "|| ");
 
    out << "(<";
    bool first2 = true;
    for (auto pair : t.out()) {
      if (enum_type(pair.second).size() <= 1) continue;

      out << (first2 ? "exists " : ", ") << iv(pair.first).name() << ": Msg";
      first2 = false;
    }

    if (!first2) out << " . ";

    out << "T" << t.id();
    first2 = true;
    for (auto pair : t.out()) {
      if (enum_type(pair.second).size() <= 1) continue;

      out << (first2 ? "(" : ",") << iv(pair.first).name();
      first2 = false;
    }
    if (!first2) out << ")";

    out << "> X(";
    first2 = true;
    for (const auto &qvar : qvars) {
      auto inqs = zip(t.in_queues(), t.in_functions());
      auto outqs = t.out_queues();

      // TODO: efficiency
      auto inq_it = std::find_if(
          inqs.begin(), inqs.end(),
          [&](const std::pair<XMASQueue *, const SymbolicFunction &> &pair) {
            return pair.first == qvar.q;
          });

      if (inq_it != inqs.end()) {
        out << (first2 ? "" : ", ") << size(qvar) << "+1";
      } else if (std::find_if(outqs.begin(), outqs.end(), [&](XMASQueue *q) {
                   return q == qvar.q;
                 }) != outqs.end()) {
        out << (first2 ? "" : ", ") << size(qvar) << "-1";
      } else {
        // nothing happens...
        out << (first2 ? "" : ", ") << size(qvar);
      }
      first2 = false;
    }



    out << "))" << std::endl;
    first = false;
  }
  out << "   ))" << std::endl;

  out << ")" << std::endl;

  for (auto c : components) {
    c->clearComponentExtension<InputVarXMASComponentExtension>();
  }
}