Ejemplo n.º 1
0
  void Transpose::generate(const std::vector<int>& arg, const std::vector<int>& res,
                           CodeGenerator& g) const {
    g.addAuxiliary(CodeGenerator::AUX_TRANS);

    g.body << "  trans("
           << g.work(arg[0], nnz()) << ", " << g.sparsity(dep().sparsity()) << ", "
           << g.work(res[0], nnz()) << ", " << g.sparsity(sparsity()) << ", iw);" << endl;
  }
Ejemplo n.º 2
0
  void Multiplication<TrX,TrY>::generateOperation(std::ostream &stream, const std::vector<std::string>& arg, const std::vector<std::string>& res, CodeGenerator& gen) const{
    // Check if inplace
    bool inplace = arg.at(0).compare(res.front())==0;

    // Copy first argument if not inplace
    if(!inplace){      
      stream << "  for(i=0; i<" << this->size() << "; ++i) " << res.front() << "[i]=" << arg.at(0) << "[i];" << endl;
    }

    // Perform sparse matrix multiplication
    gen.addAuxiliary(CodeGenerator::AUX_MM_TN_SPARSE);
    stream << "  casadi_mm_tn_sparse(";
    stream << arg.at(1) << ",s" << gen.getSparsity(dep(1).sparsity()) << ",";
    stream << arg.at(2) << ",s" << gen.getSparsity(dep(2).sparsity()) << ",";
    stream << res.front() << ",s" << gen.getSparsity(sparsity()) << ");" << endl;
  }