diff --git a/GenerateDoc.ps1 b/GenerateDoc.ps1 new file mode 100644 index 00000000..34df9fe9 --- /dev/null +++ b/GenerateDoc.ps1 @@ -0,0 +1,4 @@ + +docfx metadata ./docfx_project/docfx.json + +docfx build ./docfx_project/docfx.json -o ./docs \ No newline at end of file diff --git a/docfx_project/articles/intro.md b/docfx_project/articles/intro.md index a46932ec..be5395e4 100644 --- a/docfx_project/articles/intro.md +++ b/docfx_project/articles/intro.md @@ -3,7 +3,7 @@ The following pages are for the users who want to use NumSharp. Before you read the code examples you should read this page which explain some basis concepts. -An other reference can be numpy since we try our best to follow their APIs. +An other reference can be numpy since we try our best to follow their APIs (**High level - not lower level**). ## NDArray, NDStorgage and Shape @@ -27,20 +27,83 @@ NumSharp brings its own tensor / array type called **NDArray**. So now the question - .NET offers already multi-dimensional arrays - why a new array type? NumSharps NDArray offers the capability of storing any tensor (independent of dimension!) into its internal storage. -So NumSharps NDArray can store a vector, a matrix or sth with dimension 5 and higher. This is not possible with .NET arrays since each tensor type is a different class. +So NumSharps NDArray can store a vector, a matrix or sth with dimension 5 and higher. This is not possible with .NET arrays since each tensor type is a different class. This offers users the possibility to use same methods for different tensor types. Now the next question - how a NDArray can do this? -First of all we need to be a little bit more abstract. Why we use tensors? Because we want to store data and we want to get them. How we get and set them? We get and set via indexes (which are always integers). So just this data are important and the corresponding indexes. +First of all we need to be a little bit more abstract. Why we use tensors? Because we want to store data and we want to get them. How we get and set them? We get and set via indexes (which are always integers). So just this data are important and the corresponding indexes. That's it. Data + Indexes. :) With this in mind we easily can understand the NDStorage of NumSharp. -NDStorage is an object which stores the data of a tesor in a single 1D array. Since it is a 1D array independend of the tensor dimension NDStorage can be used for all kind of tensors. +NDStorage is an object which stores the data of a tesor in a single 1D array. Since it is a 1D array independend of the tensor dimension NDStorage can be used for all kind of tensors. A vector is stored inside a 1D array, a matrix, a 3 dimensional tensor and so on. -**But hold on! How the data comes into this 1D array?** +**But hold on! How the data comes into this 1D arrayand how we get them back?** NDStorage has a property called "shape". The shape is a small but important class in NumSharp. It stores the dimensions and most important! it determines which element in the 1D array is selected by given indexes. +**Vector** + +Imagine a 1D tensor (a vector). Here it is easy because you can access the data with a single index like 'a = np[idx]'. The internal data store in NDStorage is a 1D array - so index to access is the same index in internal storage. + +**Matrix** + +Here it is a little bit more tricky. Each data element is stored by 2 indexes like np[idx,jdx] = 5. The internal storage is a 1D array so .... there must be a way to map the 2 indexes [idx,jdx] at NDArray level to a single index [kdx] in NDStorage level. + +Indeed there is! + +Not just in NumSharp but also in many other frameworks, libs or (general spoken) languages it is good style to store the elements of a matrix row wise or column wise into a 1D array. For a more professional description you can check https://en.wikipedia.org/wiki/Row-_and_column-major_order. Row wise Layout and column wise layout often also called row major and column major. + +General spoken when imagine a matrix as a table - Row wise means that you start with element [0,0] (as your first element in 1D array) and take elements from columns of 1st row (and store them in the 1D array) until all elements of the 1st row are stored inside the 1D array. You go on with the 2nd row - take element [1,0],[1,1],[1,2],...,[1,n-1]. Go on with this pattern until all elements are inside the 1D array. + +Column wise also starts with the element [0,0] but! it stays in the 1st column and takes elements along the rows until all elements from 1st column is stored. Repeat this with 2nd column, 3rd and so on. + +The image below (taken from https://en.wikipedia.org/wiki/File:Row_and_column_major_order.svg) shows again the 'algorithm' for storing data from matrix to vector. + + +![Row Wise Column Wise](../images/rowWise_ColumnWise.png) + + + +**N dim tensor** + +Now we come to the most tricky question - how to store a general n dimensional tensor inside a 1D array. + +Short anwser - exactly like a matrix - just more generalized. + +First we look again the row wise order. + +[0,0] -> [0,1] -> [0,2] -> [0,3] -> [0,n-1] -> [1,0] -> [1,1] -> [1,2] -> [1,3] -> ... + +So here we stay in one dimension (the first / rows) and fill the other dimensions until the dimension is full. +After we switch to the next higher level of dimension (so change to next row). + +For higher dimensions like 3D - NumSharp follow this pattern. + +[0,0,0] -> [0,0,1] -> [0,0,2] -> [0,0,3] -> [0,0,n-1] -> [0,1,0] -> [0,1,1] -> [0,1,n-1] -> [0,2,0] -> [0,2,n-1] -> [0,m-1,0] -> ... + +General spoken - you can image it as a **backward filling layout**. + +As you can see the dimensions are filled beginning from last dimension, if one dimension is full, the dimension before is increased. + +Next we look the column wise order. + +[0,0] -> [1,0] -> [2,0] -> [3,0] -> [n-1,0] -> [0,1] -> [1,1] -> [2,1] -> [3,1] -> ... + +Again we stay in one dimension but here in the last / column. The rows are filled until the 1st column is full and next dimension is increased. + +So fill first dimension, increase next, fill again, etc. also in n dimensional tensor. + +[0,0,0] -> [1,0,0] -> [2,0,0] -> [3,0,0] -> [n-1,0,0] -> [0,1,0] -> [1,1,0] -> [n-1,1,0] -> [0,2,0] -> [n-1,2,0] -> [0,m-1,0] -> + +And this you can imagine as **forward filling layout**. + + + + + + + + diff --git a/docfx_project/docfx.json b/docfx_project/docfx.json index 726309c1..5bfcf3d3 100644 --- a/docfx_project/docfx.json +++ b/docfx_project/docfx.json @@ -5,7 +5,7 @@ { "src": "../", "files": [ - "src/**.csproj" + "src/NumSharp.Core/NumSharp.Core.csproj" ] } ], diff --git a/docfx_project/images/rowWise_ColumnWise.png b/docfx_project/images/rowWise_ColumnWise.png new file mode 100644 index 00000000..208b2c0c Binary files /dev/null and b/docfx_project/images/rowWise_ColumnWise.png differ diff --git a/docs/api/NumSharp.Core.Extensions.NDArrayExtensions.html b/docs/api/NumSharp.Core.Extensions.NDArrayExtensions.html new file mode 100644 index 00000000..11bb009e --- /dev/null +++ b/docs/api/NumSharp.Core.Extensions.NDArrayExtensions.html @@ -0,0 +1,317 @@ + + + + + + + + Class NDArrayExtensions + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.Extensions.html b/docs/api/NumSharp.Core.Extensions.html new file mode 100644 index 00000000..fa3270bb --- /dev/null +++ b/docs/api/NumSharp.Core.Extensions.html @@ -0,0 +1,117 @@ + + + + + + + + Namespace NumSharp.Core.Extensions + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.Interfaces.IShape.html b/docs/api/NumSharp.Core.Interfaces.IShape.html new file mode 100644 index 00000000..92beaabd --- /dev/null +++ b/docs/api/NumSharp.Core.Interfaces.IShape.html @@ -0,0 +1,495 @@ + + + + + + + + Interface IShape + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.Interfaces.IStorage.html b/docs/api/NumSharp.Core.Interfaces.IStorage.html new file mode 100644 index 00000000..816eb847 --- /dev/null +++ b/docs/api/NumSharp.Core.Interfaces.IStorage.html @@ -0,0 +1,968 @@ + + + + + + + + Interface IStorage + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.Interfaces.html b/docs/api/NumSharp.Core.Interfaces.html new file mode 100644 index 00000000..be3b90c7 --- /dev/null +++ b/docs/api/NumSharp.Core.Interfaces.html @@ -0,0 +1,119 @@ + + + + + + + + Namespace NumSharp.Core.Interfaces + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.LAPACK.html b/docs/api/NumSharp.Core.LAPACK.html new file mode 100644 index 00000000..da2b75f1 --- /dev/null +++ b/docs/api/NumSharp.Core.LAPACK.html @@ -0,0 +1,521 @@ + + + + + + + + Class LAPACK + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.Manipulation.NumPy.html b/docs/api/NumSharp.Core.Manipulation.NumPy.html new file mode 100644 index 00000000..b05b1a3e --- /dev/null +++ b/docs/api/NumSharp.Core.Manipulation.NumPy.html @@ -0,0 +1,203 @@ + + + + + + + + Class NumPy + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.Manipulation.html b/docs/api/NumSharp.Core.Manipulation.html new file mode 100644 index 00000000..b8810658 --- /dev/null +++ b/docs/api/NumSharp.Core.Manipulation.html @@ -0,0 +1,117 @@ + + + + + + + + Namespace NumSharp.Core.Manipulation + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.NDArray.html b/docs/api/NumSharp.Core.NDArray.html new file mode 100644 index 00000000..2073ba30 --- /dev/null +++ b/docs/api/NumSharp.Core.NDArray.html @@ -0,0 +1,3349 @@ + + + + + + + + Class NDArray + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.NDArrayRandomExtensions.html b/docs/api/NumSharp.Core.NDArrayRandomExtensions.html new file mode 100644 index 00000000..7f223414 --- /dev/null +++ b/docs/api/NumSharp.Core.NDArrayRandomExtensions.html @@ -0,0 +1,193 @@ + + + + + + + + Class NDArrayRandomExtensions + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.NDArray_Legacy-1.html b/docs/api/NumSharp.Core.NDArray_Legacy-1.html new file mode 100644 index 00000000..3d584cc6 --- /dev/null +++ b/docs/api/NumSharp.Core.NDArray_Legacy-1.html @@ -0,0 +1,201 @@ + + + + + + + + Class NDArray_Legacy<TData> + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.NDStorage.html b/docs/api/NumSharp.Core.NDStorage.html new file mode 100644 index 00000000..953eada5 --- /dev/null +++ b/docs/api/NumSharp.Core.NDStorage.html @@ -0,0 +1,1393 @@ + + + + + + + + Class NDStorage + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.NumPyRandom.html b/docs/api/NumSharp.Core.NumPyRandom.html new file mode 100644 index 00000000..d0c25fb2 --- /dev/null +++ b/docs/api/NumSharp.Core.NumPyRandom.html @@ -0,0 +1,551 @@ + + + + + + + + Class NumPyRandom + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.Shape.html b/docs/api/NumSharp.Core.Shape.html new file mode 100644 index 00000000..2fabd51a --- /dev/null +++ b/docs/api/NumSharp.Core.Shape.html @@ -0,0 +1,941 @@ + + + + + + + + Class Shape + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.Slice.html b/docs/api/NumSharp.Core.Slice.html new file mode 100644 index 00000000..b1d9d012 --- /dev/null +++ b/docs/api/NumSharp.Core.Slice.html @@ -0,0 +1,313 @@ + + + + + + + + Class Slice + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.html b/docs/api/NumSharp.Core.html new file mode 100644 index 00000000..51734e21 --- /dev/null +++ b/docs/api/NumSharp.Core.html @@ -0,0 +1,138 @@ + + + + + + + + Namespace NumSharp.Core + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.matrix.html b/docs/api/NumSharp.Core.matrix.html new file mode 100644 index 00000000..d645e949 --- /dev/null +++ b/docs/api/NumSharp.Core.matrix.html @@ -0,0 +1,480 @@ + + + + + + + + Class matrix + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Core.np.html b/docs/api/NumSharp.Core.np.html new file mode 100644 index 00000000..da42fd64 --- /dev/null +++ b/docs/api/NumSharp.Core.np.html @@ -0,0 +1,2160 @@ + + + + + + + + Class np + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Generic.NDArray-1.html b/docs/api/NumSharp.Generic.NDArray-1.html new file mode 100644 index 00000000..4645f234 --- /dev/null +++ b/docs/api/NumSharp.Generic.NDArray-1.html @@ -0,0 +1,420 @@ + + + + + + + + Class NDArray<T> + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/NumSharp.Generic.html b/docs/api/NumSharp.Generic.html new file mode 100644 index 00000000..8d56944b --- /dev/null +++ b/docs/api/NumSharp.Generic.html @@ -0,0 +1,117 @@ + + + + + + + + Namespace NumSharp.Generic + + + + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+ + + + + + diff --git a/docs/api/index.html b/docs/api/index.html index 5acb79a7..564bda62 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -15,7 +15,7 @@ - + @@ -57,7 +57,14 @@