ext/nmatrix/storage/yale.h in nmatrix-0.0.5 vs ext/nmatrix/storage/yale.h in nmatrix-0.0.6
- old
+ new
@@ -88,38 +88,41 @@
YALE_STORAGE* nm_yale_storage_create(nm::dtype_t dtype, size_t* shape, size_t dim, size_t init_capacity, nm::itype_t itype);
YALE_STORAGE* nm_yale_storage_create_from_old_yale(nm::dtype_t dtype, size_t* shape, void* ia, void* ja, void* a, nm::dtype_t from_dtype);
YALE_STORAGE* nm_yale_storage_create_merged(const YALE_STORAGE* merge_template, const YALE_STORAGE* other);
void nm_yale_storage_delete(STORAGE* s);
- void nm_yale_storage_init(YALE_STORAGE* s);
+ void nm_yale_storage_init(YALE_STORAGE* s, void* default_val);
void nm_yale_storage_mark(void*);
///////////////
// Accessors //
///////////////
+ VALUE nm_yale_each_with_indices(VALUE nmatrix);
VALUE nm_yale_each_stored_with_indices(VALUE nmatrix);
void* nm_yale_storage_get(STORAGE* s, SLICE* slice);
void* nm_yale_storage_ref(STORAGE* s, SLICE* slice);
char nm_yale_storage_set(STORAGE* storage, SLICE* slice, void* v);
//char nm_yale_storage_vector_insert(YALE_STORAGE* s, size_t pos, size_t* js, void* vals, size_t n, bool struct_only, nm::dtype_t dtype, nm::itype_t itype);
//void nm_yale_storage_increment_ia_after(YALE_STORAGE* s, size_t ija_size, size_t i, size_t n);
size_t nm_yale_storage_get_size(const YALE_STORAGE* storage);
+ VALUE nm_yale_default_value(VALUE self);
+ VALUE nm_yale_map_stored(VALUE self);
+ VALUE nm_yale_map_merged_stored(VALUE left, VALUE right, VALUE init);
///////////
// Tests //
///////////
bool nm_yale_storage_eqeq(const STORAGE* left, const STORAGE* right);
//////////
// Math //
//////////
-
- STORAGE* nm_yale_storage_ew_op(nm::ewop_t op, const STORAGE* left, const STORAGE* right, VALUE scalar);
+
STORAGE* nm_yale_storage_matrix_multiply(const STORAGE_PAIR& casted_storage, size_t* resulting_shape, bool vector);
/////////////
// Utility //
/////////////
@@ -161,18 +164,20 @@
/////////////////////////
// Copying and Casting //
/////////////////////////
- STORAGE* nm_yale_storage_cast_copy(const STORAGE* rhs, nm::dtype_t new_dtype);
+ STORAGE* nm_yale_storage_cast_copy(const STORAGE* rhs, nm::dtype_t new_dtype, void*);
STORAGE* nm_yale_storage_copy_transposed(const STORAGE* rhs_base);
void nm_init_yale_functions(void);
+ VALUE nm_vector_set(int argc, VALUE* argv, VALUE self);
+
} // end of extern "C" block
namespace nm { namespace yale_storage {
/*
@@ -191,22 +196,29 @@
/*
* Clear out the D portion of the A vector (clearing the diagonal and setting
* the zero value).
*
* Note: This sets a literal 0 value. If your dtype is RUBYOBJ (a Ruby object),
- * it'll actually be INT2FIX(0) instead of a string of NULLs.
+ * it'll actually be INT2FIX(0) instead of a string of NULLs. You can actually
+ * set a default for Ruby objects other than zero -- you generally want it to
+ * be Qfalse, Qnil, or INT2FIX(0). The last is the default.
*/
template <typename DType>
- inline void clear_diagonal_and_zero(YALE_STORAGE* s) {
+ inline void clear_diagonal_and_zero(YALE_STORAGE* s, void* init_val) {
DType* a = reinterpret_cast<DType*>(s->a);
// Clear out the diagonal + one extra entry
- for (size_t i = 0; i < s->shape[0]+1; ++i) // insert Ruby zeros
- a[i] = 0;
+ if (init_val) {
+ for (size_t i = 0; i <= s->shape[0]; ++i) // insert Ruby zeros, falses, or whatever else.
+ a[i] = *reinterpret_cast<DType*>(init_val);
+ } else {
+ for (size_t i = 0; i <= s->shape[0]; ++i) // insert zeros.
+ a[i] = 0;
+ }
}
template <typename DType, typename IType>
- void init(YALE_STORAGE* s);
+ void init(YALE_STORAGE* s, void* init_val);
template <typename IType>
size_t get_size(const YALE_STORAGE* storage);
}} // end of namespace nm::yale_storage