nmatrix 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +27 -0
- data/.rspec +2 -0
- data/Gemfile +3 -5
- data/Guardfile +6 -0
- data/History.txt +33 -0
- data/Manifest.txt +41 -38
- data/README.rdoc +88 -11
- data/Rakefile +35 -53
- data/ext/nmatrix/data/complex.h +372 -0
- data/ext/nmatrix/data/data.cpp +275 -0
- data/ext/nmatrix/data/data.h +707 -0
- data/ext/nmatrix/data/rational.h +421 -0
- data/ext/nmatrix/data/ruby_object.h +446 -0
- data/ext/nmatrix/extconf.rb +101 -51
- data/ext/nmatrix/new_extconf.rb +56 -0
- data/ext/nmatrix/nmatrix.cpp +1609 -0
- data/ext/nmatrix/nmatrix.h +265 -849
- data/ext/nmatrix/ruby_constants.cpp +134 -0
- data/ext/nmatrix/ruby_constants.h +103 -0
- data/ext/nmatrix/storage/common.cpp +70 -0
- data/ext/nmatrix/storage/common.h +170 -0
- data/ext/nmatrix/storage/dense.cpp +665 -0
- data/ext/nmatrix/storage/dense.h +116 -0
- data/ext/nmatrix/storage/list.cpp +1088 -0
- data/ext/nmatrix/storage/list.h +129 -0
- data/ext/nmatrix/storage/storage.cpp +658 -0
- data/ext/nmatrix/storage/storage.h +99 -0
- data/ext/nmatrix/storage/yale.cpp +1601 -0
- data/ext/nmatrix/storage/yale.h +208 -0
- data/ext/nmatrix/ttable_helper.rb +126 -0
- data/ext/nmatrix/{yale/smmp1_header.template.c → types.h} +36 -9
- data/ext/nmatrix/util/io.cpp +295 -0
- data/ext/nmatrix/util/io.h +117 -0
- data/ext/nmatrix/util/lapack.h +1175 -0
- data/ext/nmatrix/util/math.cpp +557 -0
- data/ext/nmatrix/util/math.h +1363 -0
- data/ext/nmatrix/util/sl_list.cpp +475 -0
- data/ext/nmatrix/util/sl_list.h +255 -0
- data/ext/nmatrix/util/util.h +78 -0
- data/lib/nmatrix/blas.rb +70 -0
- data/lib/nmatrix/io/mat5_reader.rb +567 -0
- data/lib/nmatrix/io/mat_reader.rb +162 -0
- data/lib/{string.rb → nmatrix/monkeys.rb} +49 -2
- data/lib/nmatrix/nmatrix.rb +199 -0
- data/lib/nmatrix/nvector.rb +103 -0
- data/lib/nmatrix/version.rb +27 -0
- data/lib/nmatrix.rb +22 -230
- data/nmatrix.gemspec +59 -0
- data/scripts/mac-brew-gcc.sh +47 -0
- data/spec/4x4_sparse.mat +0 -0
- data/spec/4x5_dense.mat +0 -0
- data/spec/blas_spec.rb +47 -0
- data/spec/elementwise_spec.rb +164 -0
- data/spec/io_spec.rb +60 -0
- data/spec/lapack_spec.rb +52 -0
- data/spec/math_spec.rb +96 -0
- data/spec/nmatrix_spec.rb +93 -89
- data/spec/nmatrix_yale_spec.rb +52 -36
- data/spec/nvector_spec.rb +1 -1
- data/spec/slice_spec.rb +257 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/utm5940.mtx +83844 -0
- metadata +113 -71
- data/.autotest +0 -23
- data/.gemtest +0 -0
- data/ext/nmatrix/cblas.c +0 -150
- data/ext/nmatrix/dense/blas_header.template.c +0 -52
- data/ext/nmatrix/dense/elementwise.template.c +0 -107
- data/ext/nmatrix/dense/gemm.template.c +0 -159
- data/ext/nmatrix/dense/gemv.template.c +0 -130
- data/ext/nmatrix/dense/rationalmath.template.c +0 -68
- data/ext/nmatrix/dense.c +0 -307
- data/ext/nmatrix/depend +0 -18
- data/ext/nmatrix/generator/syntax_tree.rb +0 -481
- data/ext/nmatrix/generator.rb +0 -594
- data/ext/nmatrix/list.c +0 -774
- data/ext/nmatrix/nmatrix.c +0 -1977
- data/ext/nmatrix/rational.c +0 -98
- data/ext/nmatrix/yale/complexmath.template.c +0 -71
- data/ext/nmatrix/yale/elementwise.template.c +0 -46
- data/ext/nmatrix/yale/elementwise_op.template.c +0 -73
- data/ext/nmatrix/yale/numbmm.template.c +0 -94
- data/ext/nmatrix/yale/smmp1.template.c +0 -21
- data/ext/nmatrix/yale/smmp2.template.c +0 -43
- data/ext/nmatrix/yale/smmp2_header.template.c +0 -46
- data/ext/nmatrix/yale/sort_columns.template.c +0 -56
- data/ext/nmatrix/yale/symbmm.template.c +0 -54
- data/ext/nmatrix/yale/transp.template.c +0 -68
- data/ext/nmatrix/yale.c +0 -726
- data/lib/array.rb +0 -67
- data/spec/syntax_tree_spec.rb +0 -46
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/////////////////////////////////////////////////////////////////////
|
|
2
|
+
// = NMatrix
|
|
3
|
+
//
|
|
4
|
+
// A linear algebra library for scientific computation in Ruby.
|
|
5
|
+
// NMatrix is part of SciRuby.
|
|
6
|
+
//
|
|
7
|
+
// NMatrix was originally inspired by and derived from NArray, by
|
|
8
|
+
// Masahiro Tanaka: http://narray.rubyforge.org
|
|
9
|
+
//
|
|
10
|
+
// == Copyright Information
|
|
11
|
+
//
|
|
12
|
+
// SciRuby is Copyright (c) 2010 - 2012, Ruby Science Foundation
|
|
13
|
+
// NMatrix is Copyright (c) 2012, Ruby Science Foundation
|
|
14
|
+
//
|
|
15
|
+
// Please see LICENSE.txt for additional copyright notices.
|
|
16
|
+
//
|
|
17
|
+
// == Contributing
|
|
18
|
+
//
|
|
19
|
+
// By contributing source code to SciRuby, you agree to be bound by
|
|
20
|
+
// our Contributor Agreement:
|
|
21
|
+
//
|
|
22
|
+
// * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
|
|
23
|
+
//
|
|
24
|
+
// == dense.h
|
|
25
|
+
//
|
|
26
|
+
// Dense n-dimensional matrix storage.
|
|
27
|
+
|
|
28
|
+
#ifndef DENSE_H
|
|
29
|
+
#define DENSE_H
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* Standard Includes
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
#include <stdlib.h>
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Project Includes
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
#include "types.h"
|
|
42
|
+
//#include "util/math.h"
|
|
43
|
+
|
|
44
|
+
#include "data/data.h"
|
|
45
|
+
|
|
46
|
+
#include "common.h"
|
|
47
|
+
|
|
48
|
+
#include "nmatrix.h"
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Macros
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* Types
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Data
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
extern "C" {
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* Functions
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
///////////////
|
|
69
|
+
// Lifecycle //
|
|
70
|
+
///////////////
|
|
71
|
+
|
|
72
|
+
DENSE_STORAGE* nm_dense_storage_create(dtype_t dtype, size_t* shape, size_t dim, void* elements, size_t elements_length);
|
|
73
|
+
void nm_dense_storage_delete(STORAGE* s);
|
|
74
|
+
void nm_dense_storage_delete_ref(STORAGE* s);
|
|
75
|
+
void nm_dense_storage_mark(void*);
|
|
76
|
+
|
|
77
|
+
///////////////
|
|
78
|
+
// Accessors //
|
|
79
|
+
///////////////
|
|
80
|
+
|
|
81
|
+
void* nm_dense_storage_get(STORAGE* s, SLICE* slice);
|
|
82
|
+
void* nm_dense_storage_ref(STORAGE* s, SLICE* slice);
|
|
83
|
+
void nm_dense_storage_set(STORAGE* s, SLICE* slice, void* val);
|
|
84
|
+
|
|
85
|
+
///////////
|
|
86
|
+
// Tests //
|
|
87
|
+
///////////
|
|
88
|
+
|
|
89
|
+
bool nm_dense_storage_eqeq(const STORAGE* left, const STORAGE* right);
|
|
90
|
+
bool nm_dense_storage_is_symmetric(const DENSE_STORAGE* mat, int lda);
|
|
91
|
+
bool nm_dense_storage_is_hermitian(const DENSE_STORAGE* mat, int lda);
|
|
92
|
+
|
|
93
|
+
//////////
|
|
94
|
+
// Math //
|
|
95
|
+
//////////
|
|
96
|
+
|
|
97
|
+
STORAGE* nm_dense_storage_ew_op(nm::ewop_t op, const STORAGE* left, const STORAGE* right);
|
|
98
|
+
STORAGE* nm_dense_storage_matrix_multiply(const STORAGE_PAIR& casted_storage, size_t* resulting_shape, bool vector);
|
|
99
|
+
|
|
100
|
+
/////////////
|
|
101
|
+
// Utility //
|
|
102
|
+
/////////////
|
|
103
|
+
|
|
104
|
+
size_t nm_dense_storage_pos(const DENSE_STORAGE* s, const size_t* coords);
|
|
105
|
+
|
|
106
|
+
/////////////////////////
|
|
107
|
+
// Copying and Casting //
|
|
108
|
+
/////////////////////////
|
|
109
|
+
|
|
110
|
+
DENSE_STORAGE* nm_dense_storage_copy(const DENSE_STORAGE* rhs);
|
|
111
|
+
STORAGE* nm_dense_storage_copy_transposed(const STORAGE* rhs_base);
|
|
112
|
+
STORAGE* nm_dense_storage_cast_copy(const STORAGE* rhs, dtype_t new_dtype);
|
|
113
|
+
|
|
114
|
+
} // end of extern "C" block
|
|
115
|
+
|
|
116
|
+
#endif // DENSE_H
|