<commit_before>var solve = require('ndarray-lu-solve');
var crout = require('ndarray-crout-decomposition');
var ndarray = require('ndarray');
var scratch = require('ndarray-scratch');

module.exports = function (A, B, X) {
    if (A.dimension === undefined) {
        var sq = Math.sqrt(A.length);
        if (Math.floor(sq) !== sq) throw new Error('not a square length');
        A = ndarray(A, [ sq, sq ], [ 1, sq ]);
    }
    if (B.dimension === undefined) B = ndarray(B);
    if (X === undefined) {
        X = scratch.malloc([ m ]);
    }
    if (X.dimension === undefined) {
        X = ndarray(X);
    }
    
    var m = A.shape[0], n = A.shape[1];
    
    if (A.dimension !== 2) throw new Error('not a 2-dimensional matrix');
    if (m !== n) throw new Error('not a square matrix: ' + m + 'x' + n);
    
    var L = scratch.malloc([ m, m ]);
    var ok = crout(A, L, L);
    if (!ok) {
        scratch.free(L);
        return undefined;
    }
    
    var Y = scratch.malloc([ m ]);
    var res = solve(L, L, B, X, Y);
    scratch.free(Y)
    scratch.free(L);
    return res;<commit_msg>semicolons<commit_after>var solve = require('ndarray-lu-solve');
var crout = require('ndarray-crout-decomposition');
var ndarray = require('ndarray');
var scratch = require('ndarray-scratch');

module.exports = function (A, B, X) {
    if (A.dimension === undefined) {
        var sq = Math.sqrt(A.length);
        if (Math.floor(sq) !== sq) throw new Error('not a square length');
        A = ndarray(A, [ sq, sq ], [ 1, sq ]);
    }
    if (B.dimension === undefined) B = ndarray(B);

    var m = A.shape[0], n = A.shape[1];
    
    if (X === undefined) {
        X = scratch.malloc([ m ]);
    }
    if (X.dimension === undefined) {
        X = ndarray(X);
    }

    
    if (A.dimension !== 2) throw new Error('not a 2-dimensional matrix');
    if (m !== n) throw new Error('not a square matrix: ' + m + 'x' + n);
    
    var L = scratch.malloc([ m, m ]);
    var ok = crout(A, L, L);
    if (!ok) {
        scratch.free(L);
        return undefined;
    }
    
    var Y = scratch.malloc([ m ]);
    var res = solve(L, L, B, X, Y);
    scratch.free(Y)
    scratch.free(L);
    if (!res) return undefined
    return X;
{'fraction_non_alphanumeric': 0.18046804680468045, 'fraction_numerical': 0.004500450045004501, 'mean_word_length': 2.342857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6007531', 'n_tokens_mistral': 793, 'n_tokens_neox': 779, 'n_words': 223}