hi
This commit is contained in:
+1
-2
@@ -73,10 +73,9 @@ inline T max(T a, T b) {
|
||||
* make a suitable assignment operator.
|
||||
*/
|
||||
#define CC_ASSIGNMENT_OPERATOR(cl) \
|
||||
const cl&operator=(const cl&o) \
|
||||
public: const cl&operator=(const cl&o) \
|
||||
{if(this!=&o){this->~cl();new(this)cl(o);}return *this;}
|
||||
|
||||
|
||||
/**
|
||||
* Defines inequality comparators for this class, given the friend
|
||||
* operator less-than has already been defined.
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#define EXTERN_C_START__impl
|
||||
#define EXTERN_C_END__impl
|
||||
#define COMPILER_CAST__impl(cast, type, var) ((type)(var))
|
||||
#define IS_CONSTANT_EXPRESSION(x) (__builtin_constant_p(x))
|
||||
#define IS_CONSTANT_EXPRESSION__impl(x) (__builtin_constant_p(x))
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
@@ -34,7 +34,7 @@
|
||||
#define expect__impl(expr, value) (expr)
|
||||
#define likely__impl(x) (x)
|
||||
#define unlikely__impl(x) (x)
|
||||
#define IS_CONSTANT_EXPRESSION(x) (0)
|
||||
#define IS_CONSTANT_EXPRESSION__impl(x) (0)
|
||||
#define COMPILER_NORETURN__IMPL
|
||||
#define COMPILER_PRINTF__IMPL(format_arg, dotdotdot_arg)
|
||||
#define COMPILER_FUNCTIONAL__IMPL
|
||||
|
||||
@@ -95,7 +95,7 @@ extern int print_warnings;
|
||||
#define DEBUG_GOT_HERE(min_verbosity) \
|
||||
VERBOSE_ONLY( \
|
||||
unlikely(print_got_heres && debug_verbosity >= (min_verbosity)) \
|
||||
? NOTIFY("Got to line " __LINE__ " of " __func__) : NOP)
|
||||
? NOTIFY("Got to line %d of %s", __LINE__, __func__) : NOP)
|
||||
|
||||
/**
|
||||
* Conditionally emit a warning message, which may abort or pause
|
||||
|
||||
@@ -318,7 +318,9 @@ success_t DatasetInfo::ReadMatrix(TextLineReader *reader, Matrix *matrix) const
|
||||
*s = ',';
|
||||
}
|
||||
}
|
||||
reader->Error("Not enough tokens");
|
||||
reader->Error("I am expecting %"LI"d entries per row, "
|
||||
"but this line has only %"LI"d.",
|
||||
n_features, i);
|
||||
retval = SUCCESS_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
+22
-6
@@ -52,8 +52,7 @@ class Vector {
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a completely uninitialized Vector which is only useful for
|
||||
* transferring ownership to.
|
||||
* Creates a completely uninitialized Vector which must be initialized.
|
||||
*/
|
||||
Vector() {
|
||||
DEBUG_ONLY(Uninitialize_());
|
||||
@@ -217,7 +216,7 @@ class Vector {
|
||||
*/
|
||||
void MakeSubvector(index_t start_index, index_t len, Vector* dest) {
|
||||
DEBUG_BOUNDS(start_index, length_);
|
||||
DEBUG_BOUNDS(start_index + len - 1, length_);
|
||||
DEBUG_BOUNDS(start_index + len, length_ + 1);
|
||||
|
||||
dest->Alias(ptr_ + start_index, len);
|
||||
}
|
||||
@@ -367,7 +366,7 @@ class Matrix {
|
||||
CC_ASSIGNMENT_OPERATOR(Matrix);
|
||||
|
||||
/**
|
||||
* Non-initializing constructor.
|
||||
* Creates a matrix that can be initialized.
|
||||
*/
|
||||
Matrix() {
|
||||
DEBUG_ONLY(Uninitialize_());
|
||||
@@ -575,7 +574,7 @@ class Matrix {
|
||||
void MakeColumnSlice(index_t start_col, index_t n_cols_new,
|
||||
Matrix *dest) const {
|
||||
DEBUG_BOUNDS(start_col, n_cols_);
|
||||
DEBUG_BOUNDS(start_col + n_cols_new - 1, n_cols_);
|
||||
DEBUG_BOUNDS(start_col + n_cols_new, n_cols_ + 1);
|
||||
dest->Alias(ptr_ + start_col * n_rows_,
|
||||
n_rows_, n_cols_new);
|
||||
}
|
||||
@@ -618,13 +617,30 @@ class Matrix {
|
||||
dest->Alias(n_rows_ * col + ptr_, n_rows_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an alias of a subvector of particular column.
|
||||
*
|
||||
* @param col the column to alias
|
||||
* @param start_row the first row to put in the subvector
|
||||
* @param n_rows_new the number of rows of the subvector
|
||||
* @param dest a pointer to an uninitialized vector, which will be
|
||||
* initialized as an alias to the particular column's subvector
|
||||
*/
|
||||
void MakeColumnSubvector(index_t col, index_t start_row, index_t n_rows_new,
|
||||
Vector *dest) const {
|
||||
DEBUG_BOUNDS(col, n_cols_);
|
||||
DEBUG_BOUNDS(start_row, n_rows_);
|
||||
DEBUG_BOUNDS(start_row + n_rows_new, n_rows_ + 1);
|
||||
dest->Alias(n_rows_ * col + start_row + ptr_, n_rows_new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a pointer to a contiguous array corresponding to a particular
|
||||
* column.
|
||||
*
|
||||
* @param col the column number
|
||||
* @return an array where the i'th element is the i'th row of that
|
||||
* particular column
|
||||
* par ticular column
|
||||
*/
|
||||
double *GetColumnPtr(index_t col) {
|
||||
DEBUG_BOUNDS(col, n_cols_);
|
||||
|
||||
@@ -436,10 +436,13 @@ success_t la::SVDExpert(Matrix* A_garbage, double *s, double *U, double *VT) {
|
||||
s, U, m, VT, k, &d, -1, iwork, &info);
|
||||
{
|
||||
f77_integer lwork = (f77_integer)d;
|
||||
double work[lwork];
|
||||
// work for DGESDD can be large, we really do need to malloc it
|
||||
double *work = mem::Alloc<double>(lwork);
|
||||
|
||||
F77_FUNC(dgesdd)(job, m, n, A_garbage->ptr(), m,
|
||||
s, U, m, VT, k, work, lwork, iwork, &info);
|
||||
|
||||
mem::Free(work);
|
||||
}
|
||||
|
||||
return SUCCESS_FROM_LAPACK(info);
|
||||
|
||||
@@ -833,7 +833,7 @@ namespace la {
|
||||
}
|
||||
/**
|
||||
* Inverts a matrix in place
|
||||
* (\f$A^{-1}\f$).
|
||||
* (\f$A \gets A^{-1}\f$).
|
||||
*
|
||||
* @code
|
||||
* Matrix A;
|
||||
@@ -848,7 +848,7 @@ namespace la {
|
||||
success_t Inverse(Matrix *A);
|
||||
/**
|
||||
* Set a matrix to the inverse of another matrix
|
||||
* (\f$A^{-1}\f$).
|
||||
* (\f$B \gets A^{-1}\f$).
|
||||
*
|
||||
* @code
|
||||
* Matrix A;
|
||||
@@ -866,7 +866,7 @@ namespace la {
|
||||
success_t InverseOverwrite(const Matrix &A, Matrix *B);
|
||||
/**
|
||||
* Init a matrix to the inverse of another matrix
|
||||
* (\f$A^{-1}\f$).
|
||||
* (\f$B \gets A^{-1}\f$).
|
||||
*
|
||||
* @param A an N-by-N matrix to invert
|
||||
* @param B a fresh matrix to be initialized to size N-by-N
|
||||
@@ -1262,7 +1262,7 @@ namespace la {
|
||||
* SUCCESS_FAIL otherwise
|
||||
*/
|
||||
success_t Cholesky(Matrix *A_in_U_out);
|
||||
|
||||
|
||||
/**
|
||||
* Inits a matrix to the Cholesky factorization (A = U' * U).
|
||||
*
|
||||
|
||||
@@ -58,6 +58,24 @@ namespace math {
|
||||
inline double ClampNonPositive(double d) {
|
||||
return (d - fabs(d)) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clips a number between a particular range.
|
||||
*
|
||||
* @param value the number to clip
|
||||
* @param range_min the first of the range
|
||||
* @param range_max the last of the range
|
||||
* @return max(range_min, min(range_max, d))
|
||||
*/
|
||||
inline double ClampRange(double value, double range_min, double range_max) {
|
||||
if (unlikely(value < range_min)) {
|
||||
return range_min;
|
||||
} else if (unlikely(value > range_max)) {
|
||||
return range_max;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#include "discrete.h"
|
||||
|
||||
@@ -234,7 +234,7 @@ class CompileRule(dep.Rule):
|
||||
mode = params["mode"]
|
||||
my_flags = my_includes + " " + compiler.mode_dictionary[params["mode"]] + " " + self.cflags
|
||||
if not sourceextension in compiler.command_from_ext:
|
||||
raise Exception("Don't know how to compile files of type [%s]." % sourceextension)
|
||||
raise Exception("Don't know how to compile files of type '*.%s'." % sourceextension)
|
||||
command_template = compiler.command_from_ext[sourceextension]
|
||||
(source_dirname, source_basename) = os.path.split(source.name)
|
||||
compile_cmd = command_template % (my_flags, sq(source_basename), sq(object.name))
|
||||
@@ -526,7 +526,8 @@ class Loader:
|
||||
build_file_path = os.path.join(real_path, BUILD_FILE)
|
||||
print "... Reading %s" % (build_file_path)
|
||||
text = util.readfile(build_file_path)
|
||||
text = text + "\n" + posttext
|
||||
# remove DOS line feeds and add posttext
|
||||
text = text.replace("\r", "") + "\n" + posttext
|
||||
exec text in {"register" : register, "Types" : Types,
|
||||
"find" : find, "dep" : dep, "lglob" : lglob,
|
||||
"sourcerule" : sourcerule, "sourcerules" : sourcerules,
|
||||
|
||||
Reference in New Issue
Block a user