Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved lots of definitions to nmatrix.h so it can be included by other…

… libraries.
  • Loading branch information...
commit c1359ef602c284647cdcc2023c99228b83743149 1 parent d667ff8
@mohawkjohn authored
View
7 ext/nmatrix/nmatrix.cpp
@@ -60,10 +60,13 @@
/*
* Project Includes
*/
-
-#include "nmatrix.h"
+#include "types.h"
+#include "data/data.h"
#include "util/math.h"
#include "storage/storage.h"
+
+#include "nmatrix.h"
+
#include "ruby_constants.h"
/*
View
62 ext/nmatrix/nmatrix.h
@@ -46,13 +46,13 @@
* Project Includes
*/
-#include "types.h"
+//#include "types.h"
-#include "data/data.h"
+//#include "data/data.h"
-#include "math.h"
+//#include "math.h"
-#include "storage/storage.h"
+//#include "storage/storage.h"
/*
* Macros
@@ -88,6 +88,54 @@
#define SIZE_T INT64
#endif
+struct STORAGE {
+ // Common elements found in all storage types. Should not be re-arranged.
+ dtype_t dtype;
+ size_t rank;
+ size_t* shape;
+ size_t* offset;
+
+ //virtual void empty(void) = 0;
+};
+
+struct DENSE_STORAGE : STORAGE {
+ size_t* stride;
+ int count;
+ void* src;
+ void* elements;
+};
+
+
+struct YALE_STORAGE : STORAGE {
+ // Yale storage specific elements.
+ void* a;
+
+ // Strictly non-diagonal non-zero count!
+ size_t ndnz;
+
+ size_t capacity;
+ itype_t itype;
+ void* ija;
+};
+
+struct NODE {
+ size_t key;
+ void* val;
+ NODE* next;
+};
+
+
+struct LIST {
+ NODE* first;
+};
+
+
+struct LIST_STORAGE : STORAGE {
+ // List storage specific elements.
+ void* default_val;
+ LIST* rows;
+};
+
#define NM_MAX_RANK 15
#define UnwrapNMatrix(obj,var) Data_Get_Struct(obj, NMATRIX, var)
@@ -128,6 +176,12 @@
/*
* Types
*/
+enum stype_t {
+ DENSE_STORE = 0,
+ LIST_STORE = 1,
+ YALE_STORE = 2
+};
+
struct NMATRIX {
// Method of storage (csc, dense, etc).
View
11 ext/nmatrix/storage/common.h
@@ -36,6 +36,7 @@
* Project Includes
*/
#include "data/data.h"
+#include "nmatrix.h"
/*
* Macros
@@ -45,16 +46,6 @@
* Types
*/
-struct STORAGE {
- // Common elements found in all storage types. Should not be re-arranged.
- dtype_t dtype;
- size_t rank;
- size_t* shape;
- size_t* offset;
-
- //virtual void empty(void) = 0;
-};
-
// For binary operations involving matrices that need to be casted.
struct STORAGE_PAIR {
STORAGE* left;
View
9 ext/nmatrix/storage/dense.h
@@ -45,6 +45,8 @@
#include "common.h"
+#include "nmatrix.h"
+
/*
* Macros
*/
@@ -53,13 +55,6 @@
* Types
*/
-struct DENSE_STORAGE : STORAGE {
- size_t* stride;
- int count;
- void* src;
- void* elements;
-};
-
/*
* Data
*/
View
8 ext/nmatrix/storage/list.h
@@ -47,6 +47,8 @@
#include "util/sl_list.h"
+#include "nmatrix.h"
+
/*
* Macros
*/
@@ -55,11 +57,7 @@
* Types
*/
-struct LIST_STORAGE : STORAGE {
- // List storage specific elements.
- void* default_val;
- LIST* rows;
-};
+
/*
* Data
View
5 ext/nmatrix/storage/storage.h
@@ -66,11 +66,6 @@
* Types
*/
-typedef enum {
- DENSE_STORE,
- LIST_STORE,
- YALE_STORE
-} stype_t;
/*
* Data
View
13 ext/nmatrix/storage/yale.h
@@ -54,6 +54,8 @@
#include "common.h"
+#include "nmatrix.h"
+
/*
* Macros
*/
@@ -85,17 +87,6 @@
* Types
*/
-struct YALE_STORAGE : STORAGE {
- // Yale storage specific elements.
- void* a;
-
- // Strictly non-diagonal non-zero count!
- size_t ndnz;
-
- size_t capacity;
- itype_t itype;
- void* ija;
-};
/*
* Data
View
18 ext/nmatrix/util/sl_list.h
@@ -42,6 +42,8 @@
#include "data/data.h"
+#include "nmatrix.h"
+
/*
* Macros
*/
@@ -50,22 +52,6 @@
* Types
*/
-/* Singly-linked ordered list
- * - holds keys and values
- * - no duplicate keys
- * - keys are ordered
- * - values may be lists themselves
- */
-typedef struct l_node {
- size_t key;
- void* val;
- struct l_node* next;
-} NODE;
-
-typedef struct {
- NODE* first;
-} LIST;
-
/*
* Data
*/
View
2  nmatrix.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
gem.summary = "NMatrix is an experimental linear algebra library for Ruby, written mostly in C."
gem.description = "NMatrix is an experimental linear algebra library for Ruby, written mostly in C."
gem.homepage = 'http://sciruby.com'
- gem.authors = ['John Woods']
+ gem.authors = ['John Woods', 'Chris Wailes', 'Aleksey Timin']
gem.email = ['john.o.woods@gmail.com']
gem.post_install_message = <<-EOF
***********************************************************
Please sign in to comment.
Something went wrong with that request. Please try again.