Singular value decomposition: Difference between revisions

m
(Added alternative C++ solution)
m (→‎{{header|Wren}}: Minor tidy)
 
Line 1,167:
{{libheader|Wren-fmt}}
An embedded solution so we can use GSL to perform SVD on any m x n matrix though the example here is for a 2 x 2 matrix.
<syntaxhighlight lang="ecmascriptwren">/* svd_emdeddedSingular_value_decomposition.wren */
 
import "./fmt" for Fmt
Line 1,203:
 
We now embed this Wren script in the following C program, compile and run it.
<syntaxhighlight lang="c">/* gcc svd_embeddedSingular_value_decomposition.c -o svd_embeddedSingular_value_decomposition -lgsl -lgslcblas -lwren -lm */
 
#include <stdio.h>
Line 1,316:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "svd_embeddedSingular_value_decomposition.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
9,476

edits