Multiplication<TrX,TrY>::Multiplication(const MX& z, const MX& x, const MX& y){
   casadi_assert_message(TrX || !TrY, "Illegal combination");
   casadi_assert_message(TrX, "Not implemented");
   casadi_assert_message(!TrY,"Not implemented");
   casadi_assert_message(x.size1() == y.size1() && x.size2() == z.size1() && y.size2() == z.size2(),"Multiplication::Multiplication: dimension mismatch. Attempting to multiply trans(" << x.dimString() << ") with " << y.dimString() << " and add the result to " << z.dimString());
   setDependencies(z,x,y);
   setSparsity(z.sparsity());
 }
Esempio n. 2
0
 Assertion::Assertion(const MX& x, const MX& y, const std::string & fail_message)
     : fail_message_(fail_message) {
   casadi_assert_message(y.is_scalar(),
                         "Assertion:: assertion expression y must be scalar, but got "
                         << y.dim());
   setDependencies(x, y);
   setSparsity(x.sparsity());
 }
Esempio n. 3
0
 BinaryMX<ScX, ScY>::BinaryMX(Operation op, const MX& x, const MX& y) : op_(op) {
   setDependencies(x, y);
   if (ScX) {
     setSparsity(y.sparsity());
   } else {
     setSparsity(x.sparsity());
   }
 }
Esempio n. 4
0
  UnaryMX::UnaryMX(Operation op, MX x) : op_(op) {
    // Put a densifying node in between if necessary
    if (!operation_checker<F00Checker>(op_)) {
      x.densify();
    }

    setDependencies(x);
    setSparsity(x->sparsity());
  }
Esempio n. 5
0
Multiplication::Multiplication(const MX& x, const MX& y_trans){
  casadi_assert_message(x.size2() == y_trans.size2(),"Multiplication::Multiplication: dimension mismatch. Attempting to multiply " << x.dimString() << " with " << y_trans.dimString());
  setDependencies(x,y_trans);

  // Create the sparsity pattern for the matrix-matrix product
  CRSSparsity spres = x->sparsity().patternProduct(y_trans.sparsity());

  // Save sparsity
  setSparsity(spres);
}
Esempio n. 6
0
 HorzRepsum::HorzRepsum(const MX& x, int n) : n_(n) {
   casadi_assert(x.size2() % n == 0);
   std::vector<Sparsity> sp = horzsplit(x.sparsity(), x.size2()/n);
   Sparsity block = sp[0];
   for (int i=1;i<sp.size();++i) {
     block = block+sp[i];
   }
   Sparsity goal = repmat(block, 1, n);
   setDependencies(project(x, goal));
   setSparsity(block);
 }
Esempio n. 7
0
EvaluationMX::EvaluationMX(const FX& fcn, const std::vector<MX> &arg) : fcn_(fcn) {
      
  // Number inputs and outputs
  int num_in = fcn.getNumInputs();

  // All dependencies of the function
  vector<MX> d = arg;
  d.resize(num_in);

  setDependencies(d);
  setSparsity(CRSSparsity(1, 1, true));
}
Esempio n. 8
0
std::vector<std::shared_ptr<Task> > QueryParser::deserialize(
    const Json::Value& query,
    std::shared_ptr<Task> *result) const {
    std::vector<std::shared_ptr<Task> > tasks;
    task_map_t task_map;

    buildTasks(query, tasks, task_map);
    setDependencies(query, task_map);
    *result = getResultTask(task_map);

    return tasks;
}
Esempio n. 9
0
void PropertyStorage::deleteOrphan(LocationProperty inNode)
	{
	lassert(isOrphaned(inNode));
	markNotOrphaned(inNode);

	setDependencies(inNode, std::set<LocationProperty>());

	mValues.erase(inNode);
	mNode_LazyCleanAndLevel.drop(inNode);

	mLocationProperties.drop(inNode.getLocation(), inNode.getPropertyID());
	mClassPropertyLocations.drop(inNode.getLocation().getType()->getClassID(), inNode);
	}
void BinaryDependenciesLdd::fillAndSetDependencies(PlainText::StringRecordList& data)
{
  PlainText::StringRecordList dependencies;

  setLibrariesNameIfMissing(data);
  // Move libraries that are not found to <notFoundDependencies> list
  mNotFoundDependencies.clear();
  Mdt::Algorithm::moveIf( data, mNotFoundDependencies, isLibraryNotFound );
  // Move libraries that are not in the exclude list to <dependencies>
  Mdt::Algorithm::moveIf( data, dependencies, isLibraryNotInExcludeList );
  // Build and set the resulting dependencies
  setDependencies( stringRecordListToLibraryInfoList(dependencies) );
}
Esempio n. 11
0
  Call::Call(const Function& fcn, const vector<MX>& arg) : fcn_(fcn) {

    // Number inputs and outputs
    int num_in = fcn.n_in();
    casadi_assert_message(arg.size()==num_in, "Argument list length (" << arg.size()
                          << ") does not match number of inputs (" << num_in << ")"
                          << " for function " << fcn.name());

    // Create arguments of the right dimensions and sparsity
    vector<MX> arg1(num_in);
    for (int i=0; i<num_in; ++i) {
      arg1[i] = projectArg(arg[i], fcn_.sparsity_in(i), i);
    }
    setDependencies(arg1);
    setSparsity(Sparsity::scalar());
  }
Task::ID BatchAddDependencies::executeDependenciesAddQuery(State& state) {
	auto qBegin = dependencies.begin();
	auto qEnd = dependencies.end();
	Task::ID lastInserted =
		boost::get<Task>((*qBegin)->execute(state)).getID();
	++qBegin;

	insertedIDs.emplace_back(lastInserted);
	for (qBegin; qBegin != qEnd; ++qBegin) {
		Response r = (*qBegin)->execute(state);
		auto task = boost::get<Task>(r);
		task.setDependencies({ lastInserted });
		QueryEngine::UpdateTask(task)->execute(state);
		lastInserted = task.getID();
		insertedIDs.emplace_back(lastInserted);
	}

	return lastInserted;
}
Esempio n. 13
0
 Split::Split(const MX& x, const std::vector<int>& offset) : offset_(offset) {
   setDependencies(x);
   setSparsity(Sparsity::scalar());
 }
Esempio n. 14
0
 HorzRepmat::HorzRepmat(const MX& x, int n) : n_(n) {
   setDependencies(x);
   setSparsity(repmat(x.sparsity(), 1, n));
 }
Esempio n. 15
0
 SubAssign::SubAssign(const MX& x, const MX& y, const Slice& i, const Slice& j) : i_(i), j_(j) {
   setDependencies(x, y);
   casadi_error("not ready");
 }
Esempio n. 16
0
 Concat::Concat(const vector<MX>& x) {
   setDependencies(x);
 }
Esempio n. 17
0
OutputNode::OutputNode(const MX& parent, int oind) : oind_(oind){
  setDependencies(parent);
  
  // Save the sparsity pattern
  setSparsity(dep(0)->sparsity(oind));
}
Esempio n. 18
0
 Transpose::Transpose(const MX& x) {
   setDependencies(x);
   setSparsity(x.sparsity().T());
 }
Esempio n. 19
0
 SubRef::SubRef(const MX& x, const Slice& i, const Slice& j) : i_(i), j_(j) {
   setDependencies(x);
 }
Esempio n. 20
0
 InnerProd::InnerProd(const MX& x, const MX& y) {
   casadi_assert(x.sparsity()==y.sparsity());
   setDependencies(x, y);
   setSparsity(Sparsity::scalar());
 }
Esempio n. 21
0
Densification::Densification(const MX& x){
  setDependencies(x);
  setSparsity(CRSSparsity(x.size1(),x.size2(),true));
}
Esempio n. 22
0
 GetNonzeros::GetNonzeros(const Sparsity& sp, const MX& y) {
   setSparsity(sp);
   setDependencies(y);
 }
Esempio n. 23
0
 Determinant::Determinant(const MX& x) {
   setDependencies(x);
   setSparsity(Sparsity::dense(1, 1));
 }
Esempio n. 24
0
 Inverse::Inverse(const MX& x) {
   casadi_assert_message(x.size1()==x.size2(),
                         "Inverse: matrix must be square, but you supllied " << x.dimString());
   setDependencies(x);
   setSparsity(Sparsity::dense(x.size1(), x.size2()));
 }
Esempio n. 25
0
 Reshape::Reshape(const MX& x, Sparsity sp) {
   casadi_assert(x.size()==sp.size());
   setDependencies(x);
   setSparsity(sp);
 }
Esempio n. 26
0
void PropertyStorage::setProperty(
			LocationProperty inNode, 
			const boost::python::object& inValue, 
			const std::set< LocationProperty >& inNewDowntreeValues
			)
	{
	/****************
	 * to update a property we must do several things:
	 *
	 *		update the property value
	 * 		update the property list
	 * 		make sure we go through old dependencies and orphan any new orphans
	 * 		check that the value is different. if so, mark anybody "uptree" of this property as "dirty"
	 * 		update the level of the boost::python::object. We assume that the levels in the system are correct for
	 * 				- mutables (0)
	 * 				- clean nodes with everything clean below
	 * 			we have to be careful, in case a dirty property depends on another dirty property.
	 *
	 *******************/
	if (!mNode_LazyCleanAndLevel.hasKey(inNode))
		mNode_LazyCleanAndLevel.set(inNode, make_pair(make_pair(inNode.isLazy(), true), 0));

	bool valueChanged = true;
	bool valueExisted = mValues.find(inNode) != mValues.end();

	if (mValues.find(inNode) != mValues.end())
		{
		boost::python::object oldValue = mValues[inNode];

		if (mValues[inNode] == inValue)
			valueChanged = false;
		}
		else
		{
		//this property is new. by default it's orphaned.
		markOrphaned(inNode);
		mLocationProperties.insert(inNode.getLocation(), inNode.getPropertyID());
		mClassPropertyLocations.insert(inNode.getLocation().getType()->getClassID(), inNode);
		}

	mValues[inNode] = inValue;
	mDirtyingProperties.erase(inNode);

	setDependencies(inNode, inNewDowntreeValues);

	//std::set dirtiness
	setClean(inNode, true);
	recomputeLevel(inNode);
	recomputeLaziness(inNode);

	//now we have to std::set the cleanliness of our parents
	if (valueChanged)
		{
		//we mark all our uptrees as dirty
		const std::set<LocationProperty>& uptree(mDependencies.getKeys(inNode));

		for (std::set<LocationProperty>::const_iterator it = uptree.begin(); it != uptree.end(); ++it)
			{
			setClean(*it, false);
			mDirtyingProperties[*it].insert(inNode);
			}

		if (valueExisted && isRoot(inNode))
			{
			std::set<WeakRootPtr> toDrop;
			std::set<WeakRootPtr>::const_iterator end = mNodeRoots.find(inNode)->second.end();
			std::set<WeakRootPtr>::const_iterator it = mNodeRoots.find(inNode)->second.begin();

			for (;it != end; ++it)
				{
				RootPtr r = it->lock();
				if (!r)
					toDrop.insert(*it);
					else
					r->changed();
				}
			end = toDrop.end();
			it = toDrop.begin();
			for (;it != end; ++it)
				dropRootNode(inNode, *it);
			}
		}

	}
Esempio n. 27
0
 Solve<Tr>::Solve(const MX& r, const MX& A, const LinearSolver& linear_solver) : linear_solver_(linear_solver){
   casadi_assert_message(r.size1() == A.size2(),"Solve::Solve: dimension mismatch.");
   setDependencies(r,A);
   setSparsity(r.sparsity());
 }
Esempio n. 28
0
 Project::Project(const MX& x, const Sparsity& sp) {
   setDependencies(x);
   setSparsity(Sparsity(sp));
 }