Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adapting sparse support for ADOL-C 2.1.5 to make it independent from …

…colpack to compute sparsity patterns

commented some code for sparse_hess sparse_jac
  • Loading branch information...
commit ab272a93de49b44ef2182c2e7f3ae450ff221e88 1 parent dec4545
Sebastian F. Walter authored
6 adolc/__init__.py
View
@@ -6,9 +6,11 @@
try:
import sparse
except:
- print 'Notice: sparse drivers not available'
-
+ print 'adolc Notice: sparse drivers not available'
+# testing
+from numpy.testing import Tester
+test = Tester().test
__doc__ = """
Adolc: Algorithmic Differentiation Software
2  adolc/sparse/SConscript
View
@@ -1,7 +1,7 @@
Import('env')
Import('adolc_include_path')
-colpack = env.SharedLibrary(target='_colpack',
+colpack = env.SharedLibrary(target='_sparse',
source=['src/py_sparse_adolc.cpp',
'src/num_util.cpp',
adolc_include_path +'/sparse/sparsedrivers.cpp',
206 adolc/sparse/src/py_sparse_adolc.cpp
View
@@ -27,74 +27,74 @@ bp::list wrapped_jac_pat(short tape_tag, bpn::array &bpn_x,bpn::array &bpn_optio
}
-bp::list wrapped_sparse_jac_no_repeat(short tape_tag, bpn::array &bpn_x, bpn::array &bpn_options){
- int tape_stats[STAT_SIZE];
- tapestats(tape_tag, tape_stats);
- int N = tape_stats[NUM_INDEPENDENTS];
- int M = tape_stats[NUM_DEPENDENTS];
-
- double* x = (double*) nu::data(bpn_x);
- int* options = (int*) nu::data(bpn_options);
-// int options[4] = {1,1,0,0};
+// bp::list wrapped_sparse_jac_no_repeat(short tape_tag, bpn::array &bpn_x, bpn::array &bpn_options){
+// int tape_stats[STAT_SIZE];
+// tapestats(tape_tag, tape_stats);
+// int N = tape_stats[NUM_INDEPENDENTS];
+// int M = tape_stats[NUM_DEPENDENTS];
+
+// double* x = (double*) nu::data(bpn_x);
+// int* options = (int*) nu::data(bpn_options);
+// // int options[4] = {1,1,0,0};
- int nnz=-1;
- unsigned int *rind = NULL;
- unsigned int *cind = NULL;
- double *values = NULL;
- sparse_jac(tape_tag, M, N, 0, x, &nnz, &rind, &cind, &values, options);
+// int nnz=-1;
+// unsigned int *rind = NULL;
+// unsigned int *cind = NULL;
+// double *values = NULL;
+// sparse_jac(tape_tag, M, N, 0, x, &nnz, &rind, &cind, &values, options);
- npy_intp ret_nnz = static_cast<npy_intp>(nnz);
- bp::object bp_rind ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_INT, (char*) rind )));
- bp::object bp_cind ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_INT, (char*) cind )));
- bp::object bp_values ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_DOUBLE, (char*) values )));
+// npy_intp ret_nnz = static_cast<npy_intp>(nnz);
+// bp::object bp_rind ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_INT, (char*) rind )));
+// bp::object bp_cind ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_INT, (char*) cind )));
+// bp::object bp_values ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_DOUBLE, (char*) values )));
- bpn::array ret_rind = boost::python::extract<boost::python::numeric::array>(bp_rind);
- bpn::array ret_cind = boost::python::extract<boost::python::numeric::array>(bp_cind);
- bpn::array ret_values = boost::python::extract<boost::python::numeric::array>(bp_values);
+// bpn::array ret_rind = boost::python::extract<boost::python::numeric::array>(bp_rind);
+// bpn::array ret_cind = boost::python::extract<boost::python::numeric::array>(bp_cind);
+// bpn::array ret_values = boost::python::extract<boost::python::numeric::array>(bp_values);
- bp::list retvals;
- retvals.append(ret_nnz);
- retvals.append(ret_rind);
- retvals.append(ret_cind);
- retvals.append(ret_values);
+// bp::list retvals;
+// retvals.append(ret_nnz);
+// retvals.append(ret_rind);
+// retvals.append(ret_cind);
+// retvals.append(ret_values);
- return retvals;
+// return retvals;
-}
+// }
-bp::list wrapped_sparse_jac_repeat(short tape_tag, bpn::array &bpn_x, npy_intp nnz, bpn::array &bpn_rind, bpn::array &bpn_cind, bpn::array &bpn_values){
- int tape_stats[STAT_SIZE];
- tapestats(tape_tag, tape_stats);
- int N = tape_stats[NUM_INDEPENDENTS];
- int M = tape_stats[NUM_DEPENDENTS];
+// bp::list wrapped_sparse_jac_repeat(short tape_tag, bpn::array &bpn_x, npy_intp nnz, bpn::array &bpn_rind, bpn::array &bpn_cind, bpn::array &bpn_values){
+// int tape_stats[STAT_SIZE];
+// tapestats(tape_tag, tape_stats);
+// int N = tape_stats[NUM_INDEPENDENTS];
+// int M = tape_stats[NUM_DEPENDENTS];
- double* x = (double*) nu::data(bpn_x);
- unsigned int* rind = (unsigned int*) nu::data(bpn_rind);
- unsigned int* cind = (unsigned int*) nu::data(bpn_cind);
- double *values = (double*) nu::data(bpn_values);
- int options[4]={0,0,0,0};
- int tmp_nnz = static_cast<int>(nnz);
+// double* x = (double*) nu::data(bpn_x);
+// unsigned int* rind = (unsigned int*) nu::data(bpn_rind);
+// unsigned int* cind = (unsigned int*) nu::data(bpn_cind);
+// double *values = (double*) nu::data(bpn_values);
+// int options[4]={0,0,0,0};
+// int tmp_nnz = static_cast<int>(nnz);
- sparse_jac(tape_tag, M, N, 1, x, &tmp_nnz, &rind, &cind, &values, options);
+// sparse_jac(tape_tag, M, N, 1, x, &tmp_nnz, &rind, &cind, &values, options);
- bp::object bp_rind ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_INT, (char*) rind )));
- bp::object bp_cind ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_INT, (char*) cind )));
- bp::object bp_values ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_DOUBLE, (char*) values )));
+// bp::object bp_rind ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_INT, (char*) rind )));
+// bp::object bp_cind ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_INT, (char*) cind )));
+// bp::object bp_values ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_DOUBLE, (char*) values )));
- bpn::array ret_rind = boost::python::extract<boost::python::numeric::array>(bp_rind);
- bpn::array ret_cind = boost::python::extract<boost::python::numeric::array>(bp_cind);
- bpn::array ret_values = boost::python::extract<boost::python::numeric::array>(bp_values);
+// bpn::array ret_rind = boost::python::extract<boost::python::numeric::array>(bp_rind);
+// bpn::array ret_cind = boost::python::extract<boost::python::numeric::array>(bp_cind);
+// bpn::array ret_values = boost::python::extract<boost::python::numeric::array>(bp_values);
- bp::list retvals;
- retvals.append(nnz);
- retvals.append(ret_rind);
- retvals.append(ret_cind);
- retvals.append(ret_values);
+// bp::list retvals;
+// retvals.append(nnz);
+// retvals.append(ret_rind);
+// retvals.append(ret_cind);
+// retvals.append(ret_values);
- return retvals;
+// return retvals;
-}
+// }
bp::list wrapped_hess_pat(short tape_tag, bpn::array &bpn_x,npy_intp option){
@@ -123,69 +123,69 @@ bp::list wrapped_hess_pat(short tape_tag, bpn::array &bpn_x,npy_intp option){
return ret_HP;
}
-bp::list wrapped_sparse_hess_no_repeat(short tape_tag, bpn::array &bpn_x, bpn::array &bpn_options){
- int tape_stats[STAT_SIZE];
- tapestats(tape_tag, tape_stats);
- int N = tape_stats[NUM_INDEPENDENTS];
+// bp::list wrapped_sparse_hess_no_repeat(short tape_tag, bpn::array &bpn_x, bpn::array &bpn_options){
+// int tape_stats[STAT_SIZE];
+// tapestats(tape_tag, tape_stats);
+// int N = tape_stats[NUM_INDEPENDENTS];
- double* x = (double*) nu::data(bpn_x);
- int* options = (int*) nu::data(bpn_options);
-// int options[2] = {0,0};
+// double* x = (double*) nu::data(bpn_x);
+// int* options = (int*) nu::data(bpn_options);
+// // int options[2] = {0,0};
- int nnz=-1;
- unsigned int *rind = NULL;
- unsigned int *cind = NULL;
- double *values = NULL;
- sparse_hess(tape_tag, N, 0, x, &nnz, &rind, &cind, &values, options);
+// int nnz=-1;
+// unsigned int *rind = NULL;
+// unsigned int *cind = NULL;
+// double *values = NULL;
+// sparse_hess(tape_tag, N, 0, x, &nnz, &rind, &cind, &values, options);
- npy_intp ret_nnz = static_cast<npy_intp>(nnz);
- bp::object bp_rind ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_INT, (char*) rind )));
- bp::object bp_cind ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_INT, (char*) cind )));
- bp::object bp_values ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_DOUBLE, (char*) values )));
+// npy_intp ret_nnz = static_cast<npy_intp>(nnz);
+// bp::object bp_rind ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_INT, (char*) rind )));
+// bp::object bp_cind ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_INT, (char*) cind )));
+// bp::object bp_values ( bp::handle<>(PyArray_SimpleNewFromData(1, &ret_nnz, PyArray_DOUBLE, (char*) values )));
- bpn::array ret_rind = boost::python::extract<boost::python::numeric::array>(bp_rind);
- bpn::array ret_cind = boost::python::extract<boost::python::numeric::array>(bp_cind);
- bpn::array ret_values = boost::python::extract<boost::python::numeric::array>(bp_values);
+// bpn::array ret_rind = boost::python::extract<boost::python::numeric::array>(bp_rind);
+// bpn::array ret_cind = boost::python::extract<boost::python::numeric::array>(bp_cind);
+// bpn::array ret_values = boost::python::extract<boost::python::numeric::array>(bp_values);
- bp::list retvals;
- retvals.append(ret_nnz);
- retvals.append(ret_rind);
- retvals.append(ret_cind);
- retvals.append(ret_values);
+// bp::list retvals;
+// retvals.append(ret_nnz);
+// retvals.append(ret_rind);
+// retvals.append(ret_cind);
+// retvals.append(ret_values);
- return retvals;
+// return retvals;
-}
+// }
-bp::list wrapped_sparse_hess_repeat(short tape_tag, bpn::array &bpn_x, npy_intp nnz, bpn::array &bpn_rind, bpn::array &bpn_cind, bpn::array &bpn_values){
- int tape_stats[STAT_SIZE];
- tapestats(tape_tag, tape_stats);
- npy_intp N = tape_stats[NUM_INDEPENDENTS];
+// bp::list wrapped_sparse_hess_repeat(short tape_tag, bpn::array &bpn_x, npy_intp nnz, bpn::array &bpn_rind, bpn::array &bpn_cind, bpn::array &bpn_values){
+// int tape_stats[STAT_SIZE];
+// tapestats(tape_tag, tape_stats);
+// npy_intp N = tape_stats[NUM_INDEPENDENTS];
- double* x = (double*) nu::data(bpn_x);
- unsigned int* rind = (unsigned int*) nu::data(bpn_rind);
- unsigned int* cind = (unsigned int*) nu::data(bpn_cind);
- double *values = (double*) nu::data(bpn_values);
- int options[2]={0,1};
- int tmp_nnz = static_cast<int>(nnz);
+// double* x = (double*) nu::data(bpn_x);
+// unsigned int* rind = (unsigned int*) nu::data(bpn_rind);
+// unsigned int* cind = (unsigned int*) nu::data(bpn_cind);
+// double *values = (double*) nu::data(bpn_values);
+// int options[2]={0,1};
+// int tmp_nnz = static_cast<int>(nnz);
- sparse_hess(tape_tag, N, 1, x, &tmp_nnz, &rind, &cind, &values, options);
+// sparse_hess(tape_tag, N, 1, x, &tmp_nnz, &rind, &cind, &values, options);
- bp::object bp_rind ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_INT, (char*) rind )));
- bp::object bp_cind ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_INT, (char*) cind )));
- bp::object bp_values ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_DOUBLE, (char*) values )));
+// bp::object bp_rind ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_INT, (char*) rind )));
+// bp::object bp_cind ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_INT, (char*) cind )));
+// bp::object bp_values ( bp::handle<>(PyArray_SimpleNewFromData(1, &nnz, PyArray_DOUBLE, (char*) values )));
- bpn::array ret_rind = boost::python::extract<boost::python::numeric::array>(bp_rind);
- bpn::array ret_cind = boost::python::extract<boost::python::numeric::array>(bp_cind);
- bpn::array ret_values = boost::python::extract<boost::python::numeric::array>(bp_values);
+// bpn::array ret_rind = boost::python::extract<boost::python::numeric::array>(bp_rind);
+// bpn::array ret_cind = boost::python::extract<boost::python::numeric::array>(bp_cind);
+// bpn::array ret_values = boost::python::extract<boost::python::numeric::array>(bp_values);
- bp::list retvals;
- retvals.append(nnz);
- retvals.append(ret_rind);
- retvals.append(ret_cind);
- retvals.append(ret_values);
+// bp::list retvals;
+// retvals.append(nnz);
+// retvals.append(ret_rind);
+// retvals.append(ret_cind);
+// retvals.append(ret_values);
- return retvals;
+// return retvals;
-}
+// }
21 adolc/sparse/src/py_sparse_adolc.hpp
View
@@ -21,34 +21,31 @@ namespace nu = num_util;
// extern int sparse_hess(short, int , int, double*, int *, unsigned int **, unsigned int **, double **,int*);
// extern int bit_vector_propagation(short, int, int, double*, unsigned int**, int*);
-
-
-
bp::list wrapped_jac_pat(short tape_tag, bpn::array &bpn_x, bpn::array &bpn_options);
-bp::list wrapped_sparse_jac_no_repeat(short tape_tag, bpn::array &bpn_x, bpn::array &bpn_options);
-bp::list wrapped_sparse_jac_repeat(short tape_tag, bpn::array &bpn_x, npy_intp nnz, bpn::array &bpn_rind, bpn::array &bpn_cind, bpn::array &bpn_values);
+// bp::list wrapped_sparse_jac_no_repeat(short tape_tag, bpn::array &bpn_x, bpn::array &bpn_options);
+// bp::list wrapped_sparse_jac_repeat(short tape_tag, bpn::array &bpn_x, npy_intp nnz, bpn::array &bpn_rind, bpn::array &bpn_cind, bpn::array &bpn_values);
bp::list wrapped_hess_pat(short tape_tag, bpn::array &bpn_x, npy_intp option);
-bp::list wrapped_sparse_hess_no_repeat(short tape_tag, bpn::array &bpn_x, bpn::array &bpn_options);
-bp::list wrapped_sparse_hess_repeat(short tape_tag, bpn::array &bpn_x, npy_intp nnz, bpn::array &bpn_rind, bpn::array &bpn_cind, bpn::array &bpn_values);
+// bp::list wrapped_sparse_hess_no_repeat(short tape_tag, bpn::array &bpn_x, bpn::array &bpn_options);
+// bp::list wrapped_sparse_hess_repeat(short tape_tag, bpn::array &bpn_x, npy_intp nnz, bpn::array &bpn_rind, bpn::array &bpn_cind, bpn::array &bpn_values);
-BOOST_PYTHON_MODULE(_colpack)
+BOOST_PYTHON_MODULE(_sparse)
{
using namespace boost::python;
import_array(); /* some kind of hack to get numpy working */
bpn::array::set_module_and_type("numpy", "ndarray"); /* some kind of hack to get numpy working */
def("jac_pat", &wrapped_jac_pat);
- def("sparse_jac_no_repeat", &wrapped_sparse_jac_no_repeat);
- def("sparse_jac_repeat", &wrapped_sparse_jac_repeat);
+ // def("sparse_jac_no_repeat", &wrapped_sparse_jac_no_repeat);
+ // def("sparse_jac_repeat", &wrapped_sparse_jac_repeat);
def("hess_pat", &wrapped_hess_pat);
- def("sparse_hess_no_repeat", &wrapped_sparse_hess_no_repeat);
- def("sparse_hess_repeat", &wrapped_sparse_hess_repeat);
+ // def("sparse_hess_no_repeat", &wrapped_sparse_hess_no_repeat);
+ // def("sparse_hess_repeat", &wrapped_sparse_hess_repeat);
}
290 adolc/sparse/wrapped_functions.py
View
@@ -1,5 +1,5 @@
-import _colpack
-from _colpack import *
+import _sparse
+from _sparse import *
import numpy
@@ -45,97 +45,97 @@ def jac_pat(tape_tag, x, options):
x = numpy.asarray(x, dtype=float)
- return _colpack.jac_pat(tape_tag, x, options)
+ return _sparse.jac_pat(tape_tag, x, options)
-def sparse_jac_no_repeat(tape_tag, x, options):
- """
- computes sparse Jacobian for a function F:R^N -> R^M without any prior information,
- i.e. this function internally finds the sparsity pattern
- of the Jacobian J, then uses Graph Coloring to find the smallest number P or Q of necessary directions
- (P in the forward mode, Q in the reverse mode)
- and computes dot(J,S) with S (N,P) array in forward mode
- or dot(S^T,J) with S(N,Q) in the reverse mode
-
- [nnz, rind, cind, values] =sparse_jac_no_repeat(tape_tag, x, options)
-
- INPUT:
- The base point x at which the Jacobian should be computed, i.e. J = dF(x)/dx
- options is a list or array of length 4
- options[0] : way of sparsity pattern computation
- 0 - propagation of index domains (default)
- 1 - propagation of bit pattern
- options[1] : test the computational graph control flow
- 0 - safe mode (default)
- 1 - tight mode
- options[2] : way of bit pattern propagation
- 0 - automatic detection (default)
- 1 - forward mode
- 2 - reverse mode
- options[3] : way of compression
- 0 - column compression (default)
- 1 - row compression
-
- OUTPUT:
- nnz is the guessed number of nonzeros in the Jacobian. This can be larger than the true number of nonzeros.
-
- sparse matrix representation in standard format:
- rind is an nnz-array of row indices
- cind is an nnz-array of column indices
- values are the corresponding Jacobian entries
- """
- assert type(tape_tag) == int
+# def sparse_jac_no_repeat(tape_tag, x, options):
+# """
+# computes sparse Jacobian for a function F:R^N -> R^M without any prior information,
+# i.e. this function internally finds the sparsity pattern
+# of the Jacobian J, then uses Graph Coloring to find the smallest number P or Q of necessary directions
+# (P in the forward mode, Q in the reverse mode)
+# and computes dot(J,S) with S (N,P) array in forward mode
+# or dot(S^T,J) with S(N,Q) in the reverse mode
- if options == None:
- options = numpy.array([1,1,0,0], dtype=numpy.int32)
+# [nnz, rind, cind, values] =sparse_jac_no_repeat(tape_tag, x, options)
- options = numpy.asarray(options,dtype=numpy.int32)
- assert numpy.ndim(options) == 1
- assert numpy.size(options) == 4
+# INPUT:
+# The base point x at which the Jacobian should be computed, i.e. J = dF(x)/dx
+# options is a list or array of length 4
+# options[0] : way of sparsity pattern computation
+# 0 - propagation of index domains (default)
+# 1 - propagation of bit pattern
+# options[1] : test the computational graph control flow
+# 0 - safe mode (default)
+# 1 - tight mode
+# options[2] : way of bit pattern propagation
+# 0 - automatic detection (default)
+# 1 - forward mode
+# 2 - reverse mode
+# options[3] : way of compression
+# 0 - column compression (default)
+# 1 - row compression
- assert numpy.ndim(x) == 1
- x = numpy.asarray(x, dtype=float)
+# OUTPUT:
+# nnz is the guessed number of nonzeros in the Jacobian. This can be larger than the true number of nonzeros.
+
+# sparse matrix representation in standard format:
+# rind is an nnz-array of row indices
+# cind is an nnz-array of column indices
+# values are the corresponding Jacobian entries
+# """
+# assert type(tape_tag) == int
+
+# if options == None:
+# options = numpy.array([1,1,0,0], dtype=numpy.int32)
- return _colpack.sparse_jac_no_repeat(tape_tag, x, options)
+# options = numpy.asarray(options,dtype=numpy.int32)
+# assert numpy.ndim(options) == 1
+# assert numpy.size(options) == 4
+# assert numpy.ndim(x) == 1
+# x = numpy.asarray(x, dtype=float)
+
+# return _colpack.sparse_jac_no_repeat(tape_tag, x, options)
-def sparse_jac_repeat(tape_tag, x, nnz, rind, cind, values):
- """
- computes sparse Jacobian J for a function F:R^N -> R^M with
- the sparsity pattern that has been computed previously (e.g. by calling sparse_jac_no_repeat)
- I guess it also reuses the options that have been set previously. So it would be not necessary to set the options again.
+# def sparse_jac_repeat(tape_tag, x, nnz, rind, cind, values):
+# """
+# computes sparse Jacobian J for a function F:R^N -> R^M with
+# the sparsity pattern that has been computed previously (e.g. by calling sparse_jac_no_repeat)
+
+# I guess it also reuses the options that have been set previously. So it would be not necessary to set the options again.
- [nnz, rind, cind, values] = sparse_jac_repeat(tape_tag, x, rind, cind, values)
+# [nnz, rind, cind, values] = sparse_jac_repeat(tape_tag, x, rind, cind, values)
- INPUT:
- The base point x at which the Jacobian should be computed, i.e. J = dF(x)/dx
+# INPUT:
+# The base point x at which the Jacobian should be computed, i.e. J = dF(x)/dx
- OUTPUT:
- nnz is the guessed number of nonzeros in the Jacobian. This can be larger than the true number of nonzeros.
+# OUTPUT:
+# nnz is the guessed number of nonzeros in the Jacobian. This can be larger than the true number of nonzeros.
- sparse matrix representation in standard format:
- rind is an nnz-array of row indices
- cind is an nnz-array of column indices
- values are the corresponding Jacobian entries
- """
- assert type(tape_tag) == int
- assert type(nnz) == int
+# sparse matrix representation in standard format:
+# rind is an nnz-array of row indices
+# cind is an nnz-array of column indices
+# values are the corresponding Jacobian entries
+# """
+# assert type(tape_tag) == int
+# assert type(nnz) == int
- assert numpy.ndim(x) == 1
- assert numpy.ndim(rind) == 1
- assert numpy.ndim(cind) == 1
- assert numpy.ndim(values) == 1
+# assert numpy.ndim(x) == 1
+# assert numpy.ndim(rind) == 1
+# assert numpy.ndim(cind) == 1
+# assert numpy.ndim(values) == 1
- x = numpy.asarray(x, dtype=float)
- rind= numpy.asarray(rind, dtype=numpy.uint32)
- cind= numpy.asarray(cind, dtype=numpy.uint32)
- values = numpy.asarray(values, dtype=float)
+# x = numpy.asarray(x, dtype=float)
+# rind= numpy.asarray(rind, dtype=numpy.uint32)
+# cind= numpy.asarray(cind, dtype=numpy.uint32)
+# values = numpy.asarray(values, dtype=float)
- return _colpack.sparse_jac_repeat(tape_tag, x, nnz, rind, cind, values)
+# return _colpack.sparse_jac_repeat(tape_tag, x, nnz, rind, cind, values)
@@ -165,85 +165,85 @@ def hess_pat(tape_tag, x, option = 0):
x = numpy.asarray(x, dtype=float)
- return _colpack.hess_pat(tape_tag, x, option)
+ return _sparse.hess_pat(tape_tag, x, option)
-def sparse_hess_no_repeat(tape_tag, x, options = None):
- """
- computes sparse Hessian for a function F:R^N -> R without any prior information,
-
- [nnz, rind, cind, values] =sparse_hess_no_repeat(tape_tag, x, options)
-
- INPUT:
- The base point x at which the Jacobian should be computed, i.e. J = dF(x)/dx
- options is a list or array of length 2
- options[0] :test the computational graph control flow
- 0 - safe mode (default)
- 1 - tight mode
- options[1] : way of recovery
- 0 - indirect recovery
- 1 - direct recovery
-
- OUTPUT:
- nnz is the guessed number of nonzeros in the Hessian. This can be larger than the true number of nonzeros.
-
- sparse matrix representation in standard format:
- rind is an nnz-array of row indices
- cind is an nnz-array of column indices
- values are the corresponding Jacobian entries
- """
- assert type(tape_tag) == int
+# def sparse_hess_no_repeat(tape_tag, x, options = None):
+# """
+# computes sparse Hessian for a function F:R^N -> R without any prior information,
+
+# [nnz, rind, cind, values] =sparse_hess_no_repeat(tape_tag, x, options)
+
+# INPUT:
+# The base point x at which the Jacobian should be computed, i.e. J = dF(x)/dx
+# options is a list or array of length 2
+# options[0] :test the computational graph control flow
+# 0 - safe mode (default)
+# 1 - tight mode
+# options[1] : way of recovery
+# 0 - indirect recovery
+# 1 - direct recovery
+
+# OUTPUT:
+# nnz is the guessed number of nonzeros in the Hessian. This can be larger than the true number of nonzeros.
+
+# sparse matrix representation in standard format:
+# rind is an nnz-array of row indices
+# cind is an nnz-array of column indices
+# values are the corresponding Jacobian entries
+# """
+# assert type(tape_tag) == int
- if options == None:
- options = numpy.array([0,0], dtype=numpy.int32)
+# if options == None:
+# options = numpy.array([0,0], dtype=numpy.int32)
- options = numpy.asarray(options,dtype=numpy.int32)
- assert numpy.ndim(options) == 1
- assert numpy.size(options) == 2
+# options = numpy.asarray(options,dtype=numpy.int32)
+# assert numpy.ndim(options) == 1
+# assert numpy.size(options) == 2
- assert numpy.ndim(x) == 1
- x = numpy.asarray(x, dtype=float)
- return _colpack.sparse_hess_no_repeat(tape_tag, x, options)
+# assert numpy.ndim(x) == 1
+# x = numpy.asarray(x, dtype=float)
+# return _colpack.sparse_hess_no_repeat(tape_tag, x, options)
-def sparse_hess_repeat(tape_tag, x, rind, cind, values):
- """
- computes sparse Hessian for a function F:R^N -> R without any prior information,
-
- [nnz, rind, cind, values] =sparse_hess_no_repeat(tape_tag, x, options)
-
- INPUT:
- The base point x at which the Jacobian should be computed, i.e. J = dF(x)/dx
- options is a list or array of length 2
- options[0] :test the computational graph control flow
- 0 - safe mode (default)
- 1 - tight mode
- options[1] : way of recovery
- 0 - indirect recovery
- 1 - direct recovery
-
- OUTPUT:
- nnz is the guessed number of nonzeros in the Hessian. This can be larger than the true number of nonzeros.
-
- sparse matrix representation in standard format:
- rind is an nnz-array of row indices
- cind is an nnz-array of column indices
- values are the corresponding Jacobian entries
- """
- assert type(tape_tag) == int
+# def sparse_hess_repeat(tape_tag, x, rind, cind, values):
+# """
+# computes sparse Hessian for a function F:R^N -> R without any prior information,
+
+# [nnz, rind, cind, values] =sparse_hess_no_repeat(tape_tag, x, options)
+
+# INPUT:
+# The base point x at which the Jacobian should be computed, i.e. J = dF(x)/dx
+# options is a list or array of length 2
+# options[0] :test the computational graph control flow
+# 0 - safe mode (default)
+# 1 - tight mode
+# options[1] : way of recovery
+# 0 - indirect recovery
+# 1 - direct recovery
+
+# OUTPUT:
+# nnz is the guessed number of nonzeros in the Hessian. This can be larger than the true number of nonzeros.
+
+# sparse matrix representation in standard format:
+# rind is an nnz-array of row indices
+# cind is an nnz-array of column indices
+# values are the corresponding Jacobian entries
+# """
+# assert type(tape_tag) == int
- assert numpy.ndim(x) == 1
- assert numpy.ndim(rind) == 1
- assert numpy.ndim(cind) == 1
- assert numpy.ndim(values) == 1
+# assert numpy.ndim(x) == 1
+# assert numpy.ndim(rind) == 1
+# assert numpy.ndim(cind) == 1
+# assert numpy.ndim(values) == 1
- nnz = int(numpy.size(rind))
+# nnz = int(numpy.size(rind))
- assert nnz == numpy.size(cind)
- assert nnz == numpy.size(values)
+# assert nnz == numpy.size(cind)
+# assert nnz == numpy.size(values)
- x = numpy.asarray(x, dtype=float)
- rind = numpy.asarray(rind, dtype=numpy.uint32)
- cind = numpy.asarray(cind, dtype=numpy.uint32)
- values = numpy.asarray(values, dtype=float)
+# x = numpy.asarray(x, dtype=float)
+# rind = numpy.asarray(rind, dtype=numpy.uint32)
+# cind = numpy.asarray(cind, dtype=numpy.uint32)
+# values = numpy.asarray(values, dtype=float)
- return _colpack.sparse_hess_repeat(tape_tag, x, nnz, rind, cind, values)
+# return _colpack.sparse_hess_repeat(tape_tag, x, nnz, rind, cind, values)
2  tests/complicated_tests.py
View
@@ -185,9 +185,11 @@ def dO_tilde(u):
ax.set_zlabel('Z')
pylab.title('Minimal Surface')
pylab.savefig('./3D_plot.png')
+ pylab.savefig('./3D_plot.eps')
#pylab.show()
except:
+ print '3d plotting with matplotlib failed'
pass
# Plot with MAYAVI
Please sign in to comment.
Something went wrong with that request. Please try again.