/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { MatrixUtilities } from "./MatrixUtilities";
import { markType } from "igniteui-angular-core";
/**
 * @hidden
 */
export let UltraCalcFunctionMinverse = /*@__PURE__*/ (() => {
    class UltraCalcFunctionMinverse extends BuiltInFunctionBase {
        evaluate(a, b) {
            let c = a.pop();
            if (c.isError) {
                return c;
            }
            let d = c.toArrayProxy();
            let e = d.getLength(0);
            if (e != d.getLength(1)) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(1));
            }
            let f;
            let g = ((() => { let h = MatrixUtilities.b(d, 0, f); f = h.p2; return h.ret; })());
            if (f != null) {
                return new ExcelCalcValue(f);
            }
            let h = ((() => { let i = MatrixUtilities.a(g, e, f); f = i.p2; return i.ret; })());
            if (f != null) {
                return new ExcelCalcValue(f);
            }
            let i = ((() => {
                let $firstRank;
                let $ret = new Array($firstRank = e);
                let $currRet = $ret;
                for (let $rankInit = 0; $rankInit < $firstRank; $rankInit++) {
                    $currRet[$rankInit] = new Array(e);
                }
                return $ret;
            })());
            for (let j = 0; j < e; j++) {
                for (let k = 0; k < e; k++) {
                    i[j][k] = new ExcelCalcValue(h[j][k]);
                }
            }
            return new ExcelCalcValue(i);
        }
        get_name() {
            return "minverse";
        }
        get name() {
            return this.get_name();
        }
        get_minArgs() {
            return 1;
        }
        get minArgs() {
            return this.get_minArgs();
        }
        get_maxArgs() {
            return 1;
        }
        get maxArgs() {
            return this.get_maxArgs();
        }
    }
    UltraCalcFunctionMinverse.$t = markType(UltraCalcFunctionMinverse, 'UltraCalcFunctionMinverse', BuiltInFunctionBase.$);
    return UltraCalcFunctionMinverse;
})();
