Ejemplo n.º 1
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());
   }
 }
Ejemplo n.º 2
0
 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());
 }
Ejemplo n.º 3
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());
 }
Ejemplo 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());
  }
Ejemplo 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);
}
Ejemplo n.º 6
0
  Vertcat::Vertcat(const std::vector<MX>& x) : Concat(x) {
    // Construct the sparsity
    casadi_assert(!x.empty());
    Sparsity sp = x.front().sparsity();
    for (vector<MX>::const_iterator i=x.begin()+1; i!=x.end(); ++i) {
      sp.append(i->sparsity());
    }

    setSparsity(sp);
  }
Ejemplo n.º 7
0
  Diagcat::Diagcat(const std::vector<MX>& x) : Concat(x) {
    // Construct the sparsity
    casadi_assert(!x.empty());
    std::vector<Sparsity> sp;
    for (int i=0;i<x.size(); ++i) {
      sp.push_back(x[i].sparsity());
    }

    setSparsity(blkdiag(sp));
  }
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
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));
}
Ejemplo n.º 10
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());
  }
Ejemplo n.º 11
0
SymbolicMX::SymbolicMX(const std::string& name, const CRSSparsity & sp) : name_(name) {
  setSparsity(sp);
}
Ejemplo n.º 12
0
 HorzRepmat::HorzRepmat(const MX& x, int n) : n_(n) {
   setDependencies(x);
   setSparsity(repmat(x.sparsity(), 1, n));
 }
Ejemplo n.º 13
0
 SymbolicMX::SymbolicMX(const std::string& name, int nrow, int ncol) : name_(name) {
   setSparsity(Sparsity::dense(nrow, ncol));
 }
Ejemplo n.º 14
0
SymbolicMX::SymbolicMX(const std::string& name, int n, int m) : name_(name) {
  setSparsity(CRSSparsity(n,m,true));
}
Ejemplo n.º 15
0
 Split::Split(const MX& x, const std::vector<int>& offset) : offset_(offset) {
   setDependencies(x);
   setSparsity(Sparsity::scalar());
 }
Ejemplo n.º 16
0
OutputNode::OutputNode(const MX& parent, int oind) : oind_(oind){
  setDependencies(parent);
  
  // Save the sparsity pattern
  setSparsity(dep(0)->sparsity(oind));
}
Ejemplo n.º 17
0
 GetNonzeros::GetNonzeros(const Sparsity& sp, const MX& y) {
   setSparsity(sp);
   setDependencies(y);
 }
Ejemplo n.º 18
0
 Transpose::Transpose(const MX& x) {
   setDependencies(x);
   setSparsity(x.sparsity().T());
 }
Ejemplo n.º 19
0
 InnerProd::InnerProd(const MX& x, const MX& y) {
   casadi_assert(x.sparsity()==y.sparsity());
   setDependencies(x, y);
   setSparsity(Sparsity::scalar());
 }
Ejemplo n.º 20
0
Densification::Densification(const MX& x){
  setDependencies(x);
  setSparsity(CRSSparsity(x.size1(),x.size2(),true));
}
Ejemplo n.º 21
0
 Project::Project(const MX& x, const Sparsity& sp) {
   setDependencies(x);
   setSparsity(Sparsity(sp));
 }
Ejemplo n.º 22
0
 Reshape::Reshape(const MX& x, Sparsity sp) {
   casadi_assert(x.size()==sp.size());
   setDependencies(x);
   setSparsity(sp);
 }
Ejemplo n.º 23
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()));
 }
Ejemplo n.º 24
0
 Determinant::Determinant(const MX& x) {
   setDependencies(x);
   setSparsity(Sparsity::dense(1, 1));
 }
Ejemplo n.º 25
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());
 }