<commit_before>/**
 * Copyright (c) 2015, <NAME>, Quintelligence d.o.o. and contributors
 * All rights reserved.
 * 
 * This source code is licensed under the FreeBSD license found in the
 * LICENSE file in the root directory of this source tree.
 */
#ifndef QMINER_LA_NODEJS_H
#define QMINER_LA_NODEJS_H

#include "la_structures_nodejs.h"
#include "la_vector_nodejs.h"

///////////////////////////////
// NodeJs-Qminer-LinAlg
/**
* Linear algebra module.
* @module la
* @example
* // import module, create a random matrix and a vector, multiply. find svd of the matrix
*/
class TNodeJsLinAlg : public node::ObjectWrap {
	friend class TNodeJsUtil;
public:
	static void Init(v8::Handle<v8::Object> exports);

private:

	class TSVDTask : public TNodeTask {
	private:
		TNodeJsFltVV* JsFltVV;
		TNodeJsSpMat* JsSpVV;
		TNodeJsFltVV* U;
		TNodeJsFltVV* V;
		TNodeJsFltV* s;
		int k;
		int Iters;
		double Tol;

	public:
		TSVDTask(const v8::FunctionCallbackInfo<v8::Value>& Args);

		v8::Handle<v8::Function> GetCallback(const v8::FunctionCallbackInfo<v8::Value>& Args);
		void Run();
		v8::Local<v8::Value> WrapResult();
	};

public:
	/**
	* Computes the truncated SVD decomposition.
	* @param {module:la.Matrix | module:la.SparseMatrix} mat - The matrix.
	* @param {number} k - The number of singular vectors to be computed.
	* @param {Object} [json] - The JSON object containing the properties iter and tol:
	* @param {number} [json.iter = 100] - The number of iterations used for the algorithm.
	* @param {number} [json.tol = 1e-6] - The tolerance number.
	* @param {function} [callback] - The callback function, that takes the error parameters (err) and the result parameter (res). 
	* <i>Only for the asynchronous function.</i>
	* @returns {Object} The JSON object svdRes which contains the SVD decomposition U*S*V^T matrices:
	* <br>svdRes.U - The dense matrix of the decomposition. Type {@link module:la.Matrix}.
	* <br>svdRes.V - The dense matrix of the decomposition. Type {@link module:la.Matrix}.<commit_msg>Minor change in the documentation.<commit_after>/**
 * Copyright (c) 2015, <NAME>, Quintelligence d.o.o. and contributors
 * All rights reserved.
 * 
 * This source code is licensed under the FreeBSD license found in the
 * LICENSE file in the root directory of this source tree.
 */
#ifndef QMINER_LA_NODEJS_H
#define QMINER_LA_NODEJS_H

#include "la_structures_nodejs.h"
#include "la_vector_nodejs.h"

///////////////////////////////
// NodeJs-Qminer-LinAlg
/**
* Linear algebra module.
* @module la
* @example
* // import module, create a random matrix and a vector, multiply. find svd of the matrix
*/
class TNodeJsLinAlg : public node::ObjectWrap {
	friend class TNodeJsUtil;
public:
	static void Init(v8::Handle<v8::Object> exports);

private:

	class TSVDTask : public TNodeTask {
	private:
		TNodeJsFltVV* JsFltVV;
		TNodeJsSpMat* JsSpVV;
		TNodeJsFltVV* U;
		TNodeJsFltVV* V;
		TNodeJsFltV* s;
		int k;
		int Iters;
		double Tol;

	public:
		TSVDTask(const v8::FunctionCallbackInfo<v8::Value>& Args);

		v8::Handle<v8::Function> GetCallback(const v8::FunctionCallbackInfo<v8::Value>& Args);
		void Run();
		v8::Local<v8::Value> WrapResult();
	};

public:
	/**
	* Computes the truncated SVD decomposition.
	* @param {module:la.Matrix | module:la.SparseMatrix} mat - The matrix.
	* @param {number} k - The number of singular vectors to be computed.
	* @param {Object} [json] - The JSON object.
	* @param {number} [json.iter = 100] - The number of iterations used for the algorithm.
	* @param {number} [json.tol = 1e-6] - The tolerance number.
	* @param {function} [callback] - The callback function, that takes the error parameters (err) and the result parameter (res). 
	* <i>Only for the asynchronous function.</i>
	* @returns {Object} The JSON object svdRes which contains the SVD decomposition U*S*V^T matrices:
	* <br>svdRes.U - The dense matrix of the decomposition. Type {@link module:la.Matrix}.
	* <br>svdRes.V - The dense matrix of the decomposition. Type {@link module:la.Matrix}.
{'fraction_non_alphanumeric': 0.13129048330842052, 'fraction_numerical': 0.009466865969108122, 'mean_word_length': 4.037641154328733, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7429099', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1324, 'n_words': 435}