Commit a9a32369 authored by André Anjos's avatar André Anjos 💬

Merge branch '1-bob-math-linsolve-parameter-documentation-in-inconsistent-order' into 'master'

Resolve "bob.math.linsolve parameter documentation in inconsistent order"

Closes #1

See merge request !13
parents 50d5c18e b326caef
Pipeline #10483 passed with stages
in 12 minutes and 30 seconds
......@@ -252,7 +252,7 @@ void bob::math::LPInteriorPoint::centeringV(const blitz::Array<double,2>& A,
// 2) Update the big system and solve it
updateLargeSystem( x, 1., m);
bob::math::linsolve( m_cache_A_large, m_cache_x_large, m_cache_b_large);
bob::math::linsolve( m_cache_A_large, m_cache_b_large, m_cache_x_large);
// 4) Find alpha and update x, lamda and mu
double alpha=1.;
......@@ -406,7 +406,7 @@ void bob::math::LPInteriorPointShortstep::solve(const blitz::Array<double,2>& A,
// 2) Update the big system and solve it
updateLargeSystem( x, sigma, m);
bob::math::linsolve( m_cache_A_large, m_cache_x_large, m_cache_b_large);
bob::math::linsolve( m_cache_A_large, m_cache_b_large, m_cache_x_large);
// 3) Update x, lamda and mu
m_lambda += m_cache_x_large( r_m+n);
......@@ -527,7 +527,7 @@ void bob::math::LPInteriorPointPredictorCorrector::solve(const blitz::Array<doub
// 2) Update the big system and solve it
updateLargeSystem( x, 0., m);
bob::math::linsolve( m_cache_A_large, m_cache_x_large, m_cache_b_large);
bob::math::linsolve( m_cache_A_large, m_cache_b_large, m_cache_x_large);
// 3) alpha=1
double alpha = 1.;
......@@ -560,7 +560,7 @@ void bob::math::LPInteriorPointPredictorCorrector::solve(const blitz::Array<doub
// 7) Update the big system and solve it
updateLargeSystem( x, 1., m);
bob::math::linsolve( m_cache_A_large, m_cache_x_large, m_cache_b_large);
bob::math::linsolve( m_cache_A_large, m_cache_b_large, m_cache_x_large);
// 8) Update x
m_lambda += m_cache_x_large(r_m+n);
......@@ -690,7 +690,7 @@ void bob::math::LPInteriorPointLongstep::solve(const blitz::Array<double,2>& A,
// 2) Update the big system and solve it
updateLargeSystem(x, m_sigma, m);
bob::math::linsolve(m_cache_A_large, m_cache_x_large, m_cache_b_large);
bob::math::linsolve(m_cache_A_large, m_cache_b_large, m_cache_x_large);
// 3) alpha=1
double alpha = 1.;
......@@ -737,4 +737,3 @@ void bob::math::LPInteriorPointLongstep::solve(const blitz::Array<double,2>& A,
// Launch the long step algorithm
solve(A, b, c, x, m_lambda, m_mu);
}
......@@ -22,8 +22,8 @@ extern "C" void dgesv_( const int *N, const int *NRHS, double *A,
extern "C" void dposv_( const char* uplo, const int *N, const int *NRHS,
double *A, const int *lda, double *B, const int *ldb, int *info);
void bob::math::linsolve(const blitz::Array<double,2>& A, blitz::Array<double,1>& x,
const blitz::Array<double,1>& b)
void bob::math::linsolve(const blitz::Array<double,2>& A,
const blitz::Array<double,1>& b, blitz::Array<double,1>& x)
{
// Check x and b
bob::core::array::assertZeroBase(x);
......@@ -35,11 +35,11 @@ void bob::math::linsolve(const blitz::Array<double,2>& A, blitz::Array<double,1>
bob::core::array::assertSameDimensionLength(A.extent(0), A.extent(1));
bob::core::array::assertSameDimensionLength(A.extent(1), b.extent(0));
bob::math::linsolve_(A, x, b);
bob::math::linsolve_(A, b, x);
}
void bob::math::linsolve_(const blitz::Array<double,2>& A, blitz::Array<double,1>& x,
const blitz::Array<double,1>& b)
void bob::math::linsolve_(const blitz::Array<double,2>& A,
const blitz::Array<double,1>& b, blitz::Array<double,1>& x)
{
// Defines dimensionality variables
const int N = A.extent(0);
......@@ -82,8 +82,8 @@ void bob::math::linsolve_(const blitz::Array<double,2>& A, blitz::Array<double,1
}
void bob::math::linsolve(const blitz::Array<double,2>& A, blitz::Array<double,2>& X,
const blitz::Array<double,2>& B)
void bob::math::linsolve(const blitz::Array<double,2>& A,
const blitz::Array<double,2>& B, blitz::Array<double,2>& X)
{
// Checks dimensionality and zero base
bob::core::array::assertZeroBase(A);
......@@ -94,12 +94,13 @@ void bob::math::linsolve(const blitz::Array<double,2>& A, blitz::Array<double,2>
bob::core::array::assertSameDimensionLength(A.extent(0), B.extent(0));
bob::core::array::assertSameDimensionLength(X.extent(1), B.extent(1));
bob::math::linsolve_(A, X, B);
bob::math::linsolve_(A, B, X);
}
void bob::math::linsolve_(const blitz::Array<double,2>& A, blitz::Array<double,2>& X,
const blitz::Array<double,2>& B)
void bob::math::linsolve_(const blitz::Array<double,2>& A,
const blitz::Array<double,2>& B, blitz::Array<double,2>& X)
{
// Defines dimensionality variables
const int N = A.extent(0);
const int P = X.extent(1);
......@@ -148,7 +149,7 @@ void bob::math::linsolve_(const blitz::Array<double,2>& A, blitz::Array<double,2
void bob::math::linsolveSympos(const blitz::Array<double,2>& A,
blitz::Array<double,1>& x, const blitz::Array<double,1>& b)
const blitz::Array<double,1>& b, blitz::Array<double,1>& x)
{
// Check x and b
bob::core::array::assertZeroBase(x);
......@@ -160,12 +161,13 @@ void bob::math::linsolveSympos(const blitz::Array<double,2>& A,
bob::core::array::assertSameDimensionLength(A.extent(0), A.extent(1));
bob::core::array::assertSameDimensionLength(A.extent(1), b.extent(0));
bob::math::linsolveSympos_(A, x, b);
bob::math::linsolveSympos_(A, b, x);
}
void bob::math::linsolveSympos_(const blitz::Array<double,2>& A,
blitz::Array<double,1>& x, const blitz::Array<double,1>& b)
const blitz::Array<double,1>& b, blitz::Array<double,1>& x)
{
// Defines dimensionality variables
const int N = A.extent(0);
......@@ -208,8 +210,8 @@ void bob::math::linsolveSympos_(const blitz::Array<double,2>& A,
x = x_blitz_lapack;
}
void bob::math::linsolveSympos(const blitz::Array<double,2>& A, blitz::Array<double,2>& X,
const blitz::Array<double,2>& B)
void bob::math::linsolveSympos(const blitz::Array<double,2>& A,
const blitz::Array<double,2>& B, blitz::Array<double,2>& X)
{
// Checks dimensionality and zero base
bob::core::array::assertZeroBase(A);
......@@ -220,11 +222,11 @@ void bob::math::linsolveSympos(const blitz::Array<double,2>& A, blitz::Array<dou
bob::core::array::assertSameDimensionLength(A.extent(0), B.extent(0));
bob::core::array::assertSameDimensionLength(X.extent(1), B.extent(1));
bob::math::linsolveSympos_(A, X, B);
bob::math::linsolveSympos_(A, B, X);
}
void bob::math::linsolveSympos_(const blitz::Array<double,2>& A, blitz::Array<double,2>& X,
const blitz::Array<double,2>& B)
void bob::math::linsolveSympos_(const blitz::Array<double,2>& A,
const blitz::Array<double,2>& B, blitz::Array<double,2>& X)
{
// Defines dimensionality variables
const int N = A.extent(0);
......@@ -275,8 +277,9 @@ void bob::math::linsolveSympos_(const blitz::Array<double,2>& A, blitz::Array<do
void bob::math::linsolveCGSympos(const blitz::Array<double,2>& A, blitz::Array<double,1>& x,
const blitz::Array<double,1>& b, const double acc, const int max_iter)
void bob::math::linsolveCGSympos(const blitz::Array<double,2>& A,
const blitz::Array<double,1>& b, blitz::Array<double,1>& x,
const double acc, const int max_iter)
{
// Dimensionality of the problem
const int N = b.extent(0);
......@@ -291,11 +294,12 @@ void bob::math::linsolveCGSympos(const blitz::Array<double,2>& A, blitz::Array<d
bob::core::array::assertSameDimensionLength(A.extent(0), N);
bob::core::array::assertSameDimensionLength(A.extent(1), N);
bob::math::linsolveCGSympos_(A, x, b, acc, max_iter);
bob::math::linsolveCGSympos_(A, b, x, acc, max_iter);
}
void bob::math::linsolveCGSympos_(const blitz::Array<double,2>& A, blitz::Array<double,1>& x,
const blitz::Array<double,1>& b, const double acc, const int max_iter)
void bob::math::linsolveCGSympos_(const blitz::Array<double,2>& A,
const blitz::Array<double,1>& b, blitz::Array<double,1>& x,
const double acc, const int max_iter)
{
// Dimensionality of the problem
const int N = b.extent(0);
......@@ -347,4 +351,3 @@ void bob::math::linsolveCGSympos_(const blitz::Array<double,2>& A, blitz::Array<
// TODO return best_res and number of iterations?
//double res = best_res;
}
......@@ -9,7 +9,7 @@
#define BOB_MATH_CONFIG_H
/* Macros that define versions and important names */
#define BOB_MATH_API_VERSION 0x0200
#define BOB_MATH_API_VERSION 0x0201
#ifdef BOB_IMPORT_VERSION
......
......@@ -23,10 +23,10 @@ namespace bob { namespace math {
* @param x The x vector of the system A*x=b which will be updated
* at the end of the function.
*/
void linsolve(const blitz::Array<double,2>& A, blitz::Array<double,1>& x,
const blitz::Array<double,1>& b);
void linsolve_(const blitz::Array<double,2>& A, blitz::Array<double,1>& x,
const blitz::Array<double,1>& b);
void linsolve(const blitz::Array<double,2>& A,
const blitz::Array<double,1>& b, blitz::Array<double,1>& x);
void linsolve_(const blitz::Array<double,2>& A,
const blitz::Array<double,1>& b, blitz::Array<double,1>& x);
/**
* @brief Function which solves a linear system of equation using the
......@@ -36,10 +36,10 @@ namespace bob { namespace math {
* @param X The X matrix of the system A*X=B which will be updated
* at the end of the function (size NxP).
*/
void linsolve(const blitz::Array<double,2>& A, blitz::Array<double,2>& X,
const blitz::Array<double,2>& B);
void linsolve_(const blitz::Array<double,2>& A, blitz::Array<double,2>& X,
const blitz::Array<double,2>& B);
void linsolve(const blitz::Array<double,2>& A,
const blitz::Array<double,2>& B, blitz::Array<double,2>& X);
void linsolve_(const blitz::Array<double,2>& A,
const blitz::Array<double,2>& B, blitz::Array<double,2>& X);
/**
* @brief Function which solves a symmetric positive definite linear
......@@ -53,9 +53,9 @@ namespace bob { namespace math {
* at the end of the function (size N)
*/
void linsolveSympos(const blitz::Array<double,2>& A,
blitz::Array<double,1>& x, const blitz::Array<double,1>& b);
const blitz::Array<double,1>& b, blitz::Array<double,1>& x);
void linsolveSympos_(const blitz::Array<double,2>& A,
blitz::Array<double,1>& x, const blitz::Array<double,1>& b);
const blitz::Array<double,1>& b, blitz::Array<double,1>& x);
/**
* @brief Function which solves a symmetric positive definite linear
......@@ -69,9 +69,9 @@ namespace bob { namespace math {
* at the end of the function (size NxP)
*/
void linsolveSympos(const blitz::Array<double,2>& A,
blitz::Array<double,2>& X, const blitz::Array<double,2>& B);
const blitz::Array<double,2>& B, blitz::Array<double,2>& X);
void linsolveSympos_(const blitz::Array<double,2>& A,
blitz::Array<double,2>& X, const blitz::Array<double,2>& B);
const blitz::Array<double,2>& B, blitz::Array<double,2>& X);
/**
......@@ -86,12 +86,13 @@ namespace bob { namespace math {
* norm(Ax-b)/norm(b) < acc
* @param max_iter The maximum number of iterations
*/
void linsolveCGSympos(const blitz::Array<double,2>& A, blitz::Array<double,1>& x,
const blitz::Array<double,1>& b, const double acc, const int max_iter);
void linsolveCGSympos_(const blitz::Array<double,2>& A, blitz::Array<double,1>& x,
const blitz::Array<double,1>& b, const double acc, const int max_iter);
void linsolveCGSympos(const blitz::Array<double,2>& A,
const blitz::Array<double,1>& b, blitz::Array<double,1>& x,
const double acc, const int max_iter);
void linsolveCGSympos_(const blitz::Array<double,2>& A,
const blitz::Array<double,1>& b, blitz::Array<double,1>& x,
const double acc, const int max_iter);
}}
#endif /* BOB_MATH_LINSOLVE_H */
This diff is collapsed.
/**
* @author Andre Anjos <andre.anjos@idiap.ch>
* @date Wed 4 Dec 15:26:54 2013
* @date Wed 4 Dec 15:26:54 2013
*
* @brief Declaration of components relevant for main.cpp
*/
......@@ -8,8 +8,9 @@
#include <Python.h>
PyObject* py_linsolve(PyObject*, PyObject* args, PyObject* kwargs);
PyObject* py_linsolve_nocheck(PyObject*, PyObject* args, PyObject* kwargs);
PyObject* py_linsolve_sympos(PyObject*, PyObject* args, PyObject* kwargs);
PyObject* py_linsolve_sympos_nocheck(PyObject*, PyObject* args, PyObject* kwargs);
PyObject* py_linsolve_cg_sympos(PyObject*, PyObject* args, PyObject* kwargs);
PyObject* py_linsolve_cg_sympos_nocheck(PyObject*, PyObject* args, PyObject* kwargs);
extern bob::extension::FunctionDoc s_linsolve;
extern bob::extension::FunctionDoc s_linsolve_sympos;
extern bob::extension::FunctionDoc s_linsolve_cg_sympos;
This diff is collapsed.
......@@ -72,53 +72,6 @@ PyObject* py_pavx (PyObject*, PyObject* args, PyObject* kwds) {
}
PyObject* py_pavx_nocheck (PyObject*, PyObject* args, PyObject* kwds) {
/* Parses input arguments in a single shot */
static const char* const_kwlist[] = { "input", "output", 0 /* Sentinel */ };
static char** kwlist = const_cast<char**>(const_kwlist);
PyBlitzArrayObject* input = 0;
PyBlitzArrayObject* output = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&O&",
kwlist,
&PyBlitzArray_Converter, &input,
&PyBlitzArray_OutputConverter, &output
)) return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
auto output_ = make_safe(output);
// can only handle 1D arrays
if (input->ndim != 1 || output->ndim != 1) {
PyErr_SetString(PyExc_TypeError, "input and output arrays should be one-dimensional");
return 0;
}
// can only handle float arrays
if (input->type_num != NPY_FLOAT64 || output->type_num != NPY_FLOAT64) {
PyErr_SetString(PyExc_TypeError, "input and output arrays data types should be float (i.e. `numpy.float64' equivalents)");
return 0;
}
try {
bob::math::pavx_(*PyBlitzArrayCxx_AsBlitz<double,1>(input),
*PyBlitzArrayCxx_AsBlitz<double,1>(output));
}
catch (std::exception& e) {
PyErr_SetString(PyExc_RuntimeError, e.what());
return 0;
}
catch (...) {
PyErr_SetString(PyExc_RuntimeError, "pavx failed: unknown exception caught");
return 0;
}
Py_RETURN_NONE;
}
PyObject* py_pavx_width (PyObject*, PyObject* args, PyObject* kwds) {
/* Parses input arguments in a single shot */
......
/**
* @author Andre Anjos <andre.anjos@idiap.ch>
* @date Wed 4 Dec 17:46:18 2013
* @date Wed 4 Dec 17:46:18 2013
*
* @brief Declaration of components relevant for main.cpp
*/
......@@ -8,6 +8,5 @@
#include <Python.h>
PyObject* py_pavx(PyObject*, PyObject* args, PyObject* kwds);
PyObject* py_pavx_nocheck(PyObject*, PyObject* args, PyObject* kwds);
PyObject* py_pavx_width(PyObject*, PyObject* args, PyObject* kwds);
PyObject* py_pavx_width_height(PyObject*, PyObject* args, PyObject* kwds);
......@@ -111,79 +111,6 @@ PyObject* py_scatter (PyObject*, PyObject* args, PyObject* kwds) {
}
PyObject* py_scatter_nocheck (PyObject*, PyObject* args, PyObject* kwds) {
/* Parses input arguments in a single shot */
static const char* const_kwlist[] = { "a", "s", "m", 0 /* Sentinel */ };
static char** kwlist = const_cast<char**>(const_kwlist);
PyBlitzArrayObject* a = 0;
PyBlitzArrayObject* s = 0;
PyBlitzArrayObject* m = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&O&O&",
kwlist,
&PyBlitzArray_Converter, &a,
&PyBlitzArray_OutputConverter, &s,
&PyBlitzArray_OutputConverter, &m
)) return 0;
//protects acquired resources through this scope
auto a_ = make_safe(a);
auto s_ = make_safe(s);
auto m_ = make_safe(m);
// basic checks
if (a->ndim != 2 || (a->type_num != NPY_FLOAT32 && a->type_num != NPY_FLOAT64)) {
PyErr_SetString(PyExc_TypeError, "input data matrix `a' should be either a 32 or 64-bit float 2D array");
return 0;
}
if (s->ndim != 2 || (s->type_num != a->type_num)) {
PyErr_SetString(PyExc_TypeError, "output data matrix `s' should be either a 32 or 64-bit float 2D array, matching the data type of `a'");
return 0;
}
if (m->ndim != 1 || (m->type_num != a->type_num)) {
PyErr_SetString(PyExc_TypeError, "output data vector `m' should be either a 32 or 64-bit float 1D array, matching the data type of `a'");
return 0;
}
try {
switch (a->type_num) {
case NPY_FLOAT32:
bob::math::scatter(
*PyBlitzArrayCxx_AsBlitz<float,2>(a),
*PyBlitzArrayCxx_AsBlitz<float,2>(s),
*PyBlitzArrayCxx_AsBlitz<float,1>(m)
);
break;
case NPY_FLOAT64:
bob::math::scatter(
*PyBlitzArrayCxx_AsBlitz<double,2>(a),
*PyBlitzArrayCxx_AsBlitz<double,2>(s),
*PyBlitzArrayCxx_AsBlitz<double,1>(m)
);
break;
default:
PyErr_Format(PyExc_TypeError, "(no-check) scatter calculation currently not implemented for type '%s'", PyBlitzArray_TypenumAsString(a->type_num));
return 0;
}
}
catch (std::exception& e) {
PyErr_SetString(PyExc_RuntimeError, e.what());
return 0;
}
catch (...) {
PyErr_SetString(PyExc_RuntimeError, "(no-check) scatter calculation failed: unknown exception caught");
return 0;
}
Py_RETURN_NONE;
}
/**
* Converts the input iterable d into a tuple of PyBlitzArrayObject's. Checks
......@@ -373,94 +300,3 @@ PyObject* py_scatters (PyObject*, PyObject* args, PyObject* kwds) {
return retval;
}
PyObject* py_scatters_nocheck (PyObject*, PyObject* args, PyObject* kwds) {
/* Parses input arguments in a single shot */
static const char* const_kwlist[] = { "data", "sw", "sb", "m", 0 /* Sentinel */ };
static char** kwlist = const_cast<char**>(const_kwlist);
PyObject* data = 0;
PyBlitzArrayObject* sw = 0;
PyBlitzArrayObject* sb = 0;
PyBlitzArrayObject* m = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&O&O&O&", kwlist,
&BzTuple_Converter, &data,
&PyBlitzArray_OutputConverter, &sw,
&PyBlitzArray_OutputConverter, &sb,
&PyBlitzArray_OutputConverter, &m
)) return 0;
//protects acquired resources through this scope
auto data_ = make_safe(data);
auto sw_ = make_safe(sw);
auto sb_ = make_safe(sb);
auto m_ = make_safe(m);
PyBlitzArrayObject* first = (PyBlitzArrayObject*)PyTuple_GET_ITEM(data, 0);
if (sw->ndim != 2 || (sw->type_num != first->type_num)) {
PyErr_SetString(PyExc_TypeError, "output data matrix `sw' should be either a 32 or 64-bit float 2D array, matching the data type of `data'");
return 0;
}
if (sb->ndim != 2 || (sb->type_num != first->type_num)) {
PyErr_SetString(PyExc_TypeError, "output data matrix `sb' should be either a 32 or 64-bit float 2D array, matching the data type of `data'");
return 0;
}
if (m->ndim != 1 || (m->type_num != first->type_num)) {
PyErr_SetString(PyExc_TypeError, "output data vector `m' should be either a 32 or 64-bit float 1D array, matching the data type of `data'");
return 0;
}
try {
switch (first->type_num) {
case NPY_FLOAT32:
{
std::vector<blitz::Array<float,2>> cxxdata;
for (Py_ssize_t i=0; i<PyTuple_GET_SIZE(data); ++i) {
cxxdata.push_back(*PyBlitzArrayCxx_AsBlitz<float,2>
((PyBlitzArrayObject*)PyTuple_GET_ITEM(data,i)));
bob::math::scatters_(cxxdata,
*PyBlitzArrayCxx_AsBlitz<float,2>(sw),
*PyBlitzArrayCxx_AsBlitz<float,2>(sb),
*PyBlitzArrayCxx_AsBlitz<float,1>(m)
);
}
}
break;
case NPY_FLOAT64:
{
std::vector<blitz::Array<double,2>> cxxdata;
for (Py_ssize_t i=0; i<PyTuple_GET_SIZE(data); ++i) {
cxxdata.push_back(*PyBlitzArrayCxx_AsBlitz<double,2>
((PyBlitzArrayObject*)PyTuple_GET_ITEM(data,i)));
bob::math::scatters_(cxxdata,
*PyBlitzArrayCxx_AsBlitz<double,2>(sw),
*PyBlitzArrayCxx_AsBlitz<double,2>(sb),
*PyBlitzArrayCxx_AsBlitz<double,1>(m)
);
}
}
break;
default:
PyErr_Format(PyExc_TypeError, "(no-check) scatters calculation currently not implemented for type '%s'", PyBlitzArray_TypenumAsString(first->type_num));
return 0;
}
}
catch (std::exception& e) {
PyErr_SetString(PyExc_RuntimeError, e.what());
return 0;
}
catch (...) {
PyErr_SetString(PyExc_RuntimeError, "(no-check) scatters calculation failed: unknown exception caught");
return 0;
}
Py_RETURN_NONE;
}
/**
* @author Andre Anjos <andre.anjos@idiap.ch>
* @date Thu 5 Dec 12:10:18 2013
* @date Thu 5 Dec 12:10:18 2013
*
* @brief Declaration of components relevant for main.cpp
*/
......@@ -8,6 +8,4 @@
#include <Python.h>
PyObject* py_scatter(PyObject*, PyObject* args, PyObject* kwds);
PyObject* py_scatter_nocheck(PyObject*, PyObject* args, PyObject* kwds);
PyObject* py_scatters(PyObject*, PyObject* args, PyObject* kwds);
PyObject* py_scatters_nocheck(PyObject*, PyObject* args, PyObject* kwds);
......@@ -30,7 +30,7 @@ def test_linsolve():
x1 = numpy.ndarray((3,), 'float64')
# Computes the solution
linsolve(A,x1,b)
linsolve(A,b,x1)
x2 = linsolve(A,b)
# Compare to reference
......@@ -54,7 +54,7 @@ def test_linsolveSympos():
x1 = numpy.ndarray((3,), 'float64')
# Computes the solution
linsolve_sympos(A,x1,b)
linsolve_sympos(A,b,x1)
x2 = linsolve_sympos(A,b)
# Compare to reference
......@@ -81,7 +81,7 @@ def test_linsolveCGSympos():
# Computes the solution
eps = 1e-6
max_iter = 1000
linsolve_cg_sympos(A,x1,b,eps,max_iter)
linsolve_cg_sympos(A,b,x1,eps,max_iter)
x2 = linsolve_cg_sympos(A,b,eps,max_iter)
# Compare to reference
......
......@@ -9,7 +9,7 @@
"""
import os, sys
from bob.math import pavx, pavx_, pavxWidth, pavxWidthHeight
from bob.math import pavx, pavxWidth, pavxWidthHeight
import numpy
def pavx_check(y, ghat_ref, w_ref, h_ref):
......@@ -17,7 +17,7 @@ def pavx_check(y, ghat_ref, w_ref, h_ref):
ghat = pavx(y)
assert numpy.all(numpy.abs(ghat - ghat_ref) < 1e-4)
pavx_(y, ghat)
pavx(y, ghat)
assert numpy.all(numpy.abs(ghat - ghat_ref) < 1e-4)
w=pavxWidth(y, ghat)
assert numpy.all(numpy.abs(w - w_ref) < 1e-4)
......@@ -31,7 +31,7 @@ def test_pavx_sample1():
# Reference obtained using bosaris toolkit 1.06
y = numpy.array([ 58.4666, 67.1040, 73.1806, 77.0896, 85.8816,
89.6381, 101.6651, 102.5587, 109.7933, 117.5715,
89.6381, 101.6651, 102.5587, 109.7933, 117.5715,
118.1671, 138.3151, 141.9755, 145.7352, 159.1108,
156.8654, 168.6932, 175.2756])
ghat_ref = numpy.array([ 58.4666, 67.1040, 73.1806, 77.0896, 85.8816,
......@@ -58,7 +58,7 @@ def test_pavx_sample2():
132.1742, 140.2783, 140.2783, 150.7383, 150.7383,
150.7383, 154.7762, 180.8819])
w_ref = numpy.array([1, 1, 1, 1, 3, 1, 1, 2, 2, 3, 1, 1])
h_ref = numpy.array([ 46.1093, 64.3255, 76.5252, 89.0061, 92.4618,
h_ref = numpy.array([ 46.1093, 64.3255, 76.5252, 89.0061, 92.4618,
98.5769, 102.3841, 132.1742, 140.2783, 150.7383,
154.7762, 180.8819])
......
......@@ -9,7 +9,7 @@
"""
import os, sys
from bob.math import scatter, scatter_, scatters, scatters_
from bob.math import scatter, scatters
import numpy
import nose.tools
......@@ -112,7 +112,7 @@ def test_fast_scatter():
# This test demonstrates how to use the scatter matrix function of bob.
S = numpy.ndarray((data.shape[1], data.shape[1]), dtype=float)
M = numpy.ndarray((data.shape[1],), dtype=float)
scatter_(data, S, M)
scatter(data, S, M)
S /= (data.shape[0]-1)
# Do the same with numpy and compare. Note that with numpy we are computing
......@@ -185,7 +185,7 @@ def test_fast_scatters():
Sw = numpy.empty_like(Sw_)
Sb = numpy.empty_like(Sb_)
m = numpy.empty_like(m_)
scatters_(data, Sw, Sb, m)
scatters(data, Sw, Sb, m)
assert numpy.allclose(Sw, Sw_)
assert numpy.allclose(Sb, Sb_)
assert numpy.allclose(m, m_)
2.1.2b0
\ No newline at end of file
2.2.0b0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment