Skip to content

Commit 31f603c

Browse files
committed
Add doc blocks
1 parent a57b92d commit 31f603c

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- 2.2.0
22
- Implemented Singular Value Decomposition (SVD)
3-
- Implemented matrix pseudo (Moore-Penrose) inverse
3+
- Implemented matrix (Moore-Penrose) pseudoinverse
44
- Tensor objects now throw namespaced exceptions
55
- Optimized Reduced Row Echelon Form (RREF)
66
- Optimize eigendecomposition for symmetric matrices

ext/include/linear_algebra.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
#include <lapacke.h>
88
#include "kernel/operators.h"
99

10+
/**
11+
* Matrix-matrix multiplication i.e. linear transformation of matrices A and B.
12+
*
13+
* @param return_value
14+
* @param a
15+
* @param b
16+
*/
1017
void tensor_matmul(zval * return_value, zval * a, zval * b)
1118
{
1219
unsigned int i, j;
@@ -64,6 +71,13 @@ void tensor_matmul(zval * return_value, zval * a, zval * b)
6471
efree(vc);
6572
}
6673

74+
/**
75+
* Dot product between vectors A and B.
76+
*
77+
* @param return_value
78+
* @param a
79+
* @param b
80+
*/
6781
void tensor_dot(zval * return_value, zval * a, zval * b)
6882
{
6983
unsigned int i;
@@ -85,6 +99,12 @@ void tensor_dot(zval * return_value, zval * a, zval * b)
8599
RETVAL_DOUBLE(sigma);
86100
}
87101

102+
/**
103+
* Return the multiplicative inverse of a square matrix A.
104+
*
105+
* @param return_value
106+
* @param a
107+
*/
88108
void tensor_inverse(zval * return_value, zval * a)
89109
{
90110
unsigned int i, j;
@@ -140,6 +160,12 @@ void tensor_inverse(zval * return_value, zval * a)
140160
efree(pivots);
141161
}
142162

163+
/**
164+
* Return the (Moore-Penrose) pseudoinverse of a general matrix A.
165+
*
166+
* @param return_value
167+
* @param a
168+
*/
143169
void tensor_pseudoinverse(zval * return_value, zval * a)
144170
{
145171
unsigned int i, j;
@@ -201,6 +227,12 @@ void tensor_pseudoinverse(zval * return_value, zval * a)
201227
efree(vb);
202228
}
203229

230+
/**
231+
* Return the row echelon form of matrix A.
232+
*
233+
* @param return_value
234+
* @param a
235+
*/
204236
void tensor_ref(zval * return_value, zval * a)
205237
{
206238
unsigned int i, j;
@@ -265,6 +297,12 @@ void tensor_ref(zval * return_value, zval * a)
265297
efree(pivots);
266298
}
267299

300+
/**
301+
* Compute the Cholesky decomposition of matrix A and return the lower triangular matrix.
302+
*
303+
* @param return_value
304+
* @param a
305+
*/
268306
void tensor_cholesky(zval * return_value, zval * a)
269307
{
270308
unsigned int i, j;
@@ -314,6 +352,12 @@ void tensor_cholesky(zval * return_value, zval * a)
314352
efree(va);
315353
}
316354

355+
/**
356+
* Compute the LU factorization of matrix A and return a tuple with lower, upper, and permutation matrices.
357+
*
358+
* @param return_value
359+
* @param a
360+
*/
317361
void tensor_lu(zval * return_value, zval * a)
318362
{
319363
unsigned int i, j;
@@ -404,6 +448,12 @@ void tensor_lu(zval * return_value, zval * a)
404448
efree(pivots);
405449
}
406450

451+
/**
452+
* Compute the eigendecomposition of a general matrix A and return the eigenvalues and eigenvectors in a tuple.
453+
*
454+
* @param return_value
455+
* @param a
456+
*/
407457
void tensor_eig(zval * return_value, zval * a)
408458
{
409459
unsigned int i, j;
@@ -466,6 +516,12 @@ void tensor_eig(zval * return_value, zval * a)
466516
efree(vr);
467517
}
468518

519+
/**
520+
* Compute the eigendecomposition of a symmetric matrix A and return the eigenvalues and eigenvectors in a tuple.
521+
*
522+
* @param return_value
523+
* @param a
524+
*/
469525
void tensor_eig_symmetric(zval * return_value, zval * a)
470526
{
471527
unsigned int i, j;
@@ -524,6 +580,12 @@ void tensor_eig_symmetric(zval * return_value, zval * a)
524580
efree(wr);
525581
}
526582

583+
/**
584+
* Compute the singular value decomposition of a matrix A and return the singular values, and unitary matrices U and VT in a tuple.
585+
*
586+
* @param return_value
587+
* @param a
588+
*/
527589
void tensor_svd(zval * return_value, zval * a)
528590
{
529591
unsigned int i, j;

ext/include/settings.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
#include <cblas.h>
77
#include "kernel/operators.h"
88

9+
/**
10+
* Sets the number of threads to use when parallel processesing.
11+
*
12+
* @param return_value
13+
* @param threads
14+
*/
915
void tensor_set_num_threads(zval * return_value, zval * threads)
1016
{
1117
int n = zephir_get_intval(threads);
@@ -15,6 +21,11 @@ void tensor_set_num_threads(zval * return_value, zval * threads)
1521
RETURN_TRUE;
1622
}
1723

24+
/**
25+
* Return the number of threads to use when parallel processesing.
26+
*
27+
* @param return_value
28+
*/
1829
void tensor_get_num_threads(zval * return_value)
1930
{
2031
long threads = openblas_get_num_threads();

package.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<email>[email protected]</email>
1111
<active>yes</active>
1212
</lead>
13-
<date>2021-02-20</date>
13+
<date>2021-02-28</date>
1414
<version>
1515
<release>2.2.0</release>
1616
<api>2.2.0</api>
@@ -22,8 +22,10 @@
2222
<license uri="https://github.com/RubixML/Tensor/blob/master/LICENSE">MIT</license>
2323
<notes>
2424
- Implemented Singular Value Decomposition (SVD)
25+
- Implemented matrix (Moore-Penrose) pseudoinverse
2526
- Tensor objects now throw namespaced exceptions
2627
- Optimized Reduced Row Echelon Form (RREF)
28+
- Optimize eigendecomposition for symmetric matrices
2729
</notes>
2830
<contents>
2931
<dir name="/">

0 commit comments

Comments
 (0)