@mojir/lits 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +1145 -1105
- package/dist/cli/src/AutoCompleter/AutoCompleter.d.ts +2 -1
- package/dist/cli/src/builtin/bindingNode.d.ts +3 -3
- package/dist/cli/src/builtin/index.d.ts +0 -1
- package/dist/cli/src/builtin/interface.d.ts +3 -4
- package/dist/cli/src/builtin/specialExpressionTypes.d.ts +0 -1
- package/dist/cli/src/builtin/specialExpressions/and.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/array.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/block.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/cond.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/if.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/loop.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/loops.d.ts +4 -4
- package/dist/cli/src/builtin/specialExpressions/object.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/or.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/qq.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/recur.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/switch.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/throw.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/try.d.ts +2 -2
- package/dist/cli/src/builtin/specialExpressions/unless.d.ts +2 -2
- package/dist/cli/src/builtin/utils.d.ts +2 -2
- package/dist/cli/src/evaluator/index.d.ts +2 -2
- package/dist/cli/src/evaluator/interface.d.ts +4 -3
- package/dist/cli/src/getUndefinedSymbols/index.d.ts +2 -2
- package/dist/cli/src/parser/ParserContext.d.ts +20 -0
- package/dist/cli/src/parser/helpers.d.ts +19 -0
- package/dist/cli/src/parser/index.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/getPrecedence.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseArray.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseBindingTarget.d.ts +6 -0
- package/dist/cli/src/parser/subParsers/parseCond.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseDo.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseFunction.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
- package/dist/cli/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
- package/dist/cli/src/parser/subParsers/parseLet.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseLoop.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseNumber.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseObject.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseOperand.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseString.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseSwitch.d.ts +4 -0
- package/dist/cli/src/parser/subParsers/parseSymbol.d.ts +3 -0
- package/dist/cli/src/parser/subParsers/parseTry.d.ts +4 -0
- package/dist/cli/src/parser/types.d.ts +19 -26
- package/dist/cli/src/testFramework/index.d.ts +3 -2
- package/dist/cli/src/tokenizer/token.d.ts +0 -2
- package/dist/cli/src/tokenizer/tokenizers.d.ts +2 -2
- package/dist/cli/src/typeGuards/astNode.d.ts +18 -19
- package/dist/cli/src/typeGuards/index.d.ts +0 -1
- package/dist/cli/src/typeGuards/lits.d.ts +0 -1
- package/dist/full.esm.js +1 -1
- package/dist/full.esm.js.map +1 -1
- package/dist/full.js +1 -1
- package/dist/full.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +1 -1
- package/dist/lits.iife.js.map +1 -1
- package/dist/modules/assert.esm.js.map +1 -1
- package/dist/modules/assert.js.map +1 -1
- package/dist/modules/bitwise.esm.js.map +1 -1
- package/dist/modules/bitwise.js.map +1 -1
- package/dist/modules/collection.esm.js.map +1 -1
- package/dist/modules/collection.js.map +1 -1
- package/dist/modules/functional.esm.js.map +1 -1
- package/dist/modules/functional.js.map +1 -1
- package/dist/modules/grid.esm.js.map +1 -1
- package/dist/modules/grid.js.map +1 -1
- package/dist/modules/linear-algebra.esm.js.map +1 -1
- package/dist/modules/linear-algebra.js.map +1 -1
- package/dist/modules/matrix.esm.js.map +1 -1
- package/dist/modules/matrix.js.map +1 -1
- package/dist/modules/number-theory.esm.js.map +1 -1
- package/dist/modules/number-theory.js.map +1 -1
- package/dist/modules/random.esm.js.map +1 -1
- package/dist/modules/random.js.map +1 -1
- package/dist/modules/sequence.esm.js.map +1 -1
- package/dist/modules/sequence.js.map +1 -1
- package/dist/modules/src/AutoCompleter/AutoCompleter.d.ts +2 -1
- package/dist/modules/src/builtin/bindingNode.d.ts +3 -3
- package/dist/modules/src/builtin/index.d.ts +0 -1
- package/dist/modules/src/builtin/interface.d.ts +3 -4
- package/dist/modules/src/builtin/specialExpressionTypes.d.ts +0 -1
- package/dist/modules/src/builtin/specialExpressions/and.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/array.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/block.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/cond.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/if.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/loop.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/loops.d.ts +4 -4
- package/dist/modules/src/builtin/specialExpressions/object.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/or.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/qq.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/recur.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/switch.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/throw.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/try.d.ts +2 -2
- package/dist/modules/src/builtin/specialExpressions/unless.d.ts +2 -2
- package/dist/modules/src/builtin/utils.d.ts +2 -2
- package/dist/modules/src/evaluator/index.d.ts +2 -2
- package/dist/modules/src/evaluator/interface.d.ts +4 -3
- package/dist/modules/src/getUndefinedSymbols/index.d.ts +2 -2
- package/dist/modules/src/parser/ParserContext.d.ts +20 -0
- package/dist/modules/src/parser/helpers.d.ts +19 -0
- package/dist/modules/src/parser/index.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/getPrecedence.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseArray.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseBindingTarget.d.ts +6 -0
- package/dist/modules/src/parser/subParsers/parseCond.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseDo.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseFunction.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
- package/dist/modules/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
- package/dist/modules/src/parser/subParsers/parseLet.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseLoop.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseNumber.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseObject.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseOperand.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseString.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseSwitch.d.ts +4 -0
- package/dist/modules/src/parser/subParsers/parseSymbol.d.ts +3 -0
- package/dist/modules/src/parser/subParsers/parseTry.d.ts +4 -0
- package/dist/modules/src/parser/types.d.ts +19 -26
- package/dist/modules/src/testFramework/index.d.ts +3 -2
- package/dist/modules/src/tokenizer/token.d.ts +0 -2
- package/dist/modules/src/tokenizer/tokenizers.d.ts +2 -2
- package/dist/modules/src/typeGuards/astNode.d.ts +18 -19
- package/dist/modules/src/typeGuards/index.d.ts +0 -1
- package/dist/modules/src/typeGuards/lits.d.ts +0 -1
- package/dist/modules/string.esm.js.map +1 -1
- package/dist/modules/string.js.map +1 -1
- package/dist/modules/vector.esm.js.map +1 -1
- package/dist/modules/vector.js.map +1 -1
- package/dist/src/AutoCompleter/AutoCompleter.d.ts +2 -1
- package/dist/src/builtin/bindingNode.d.ts +3 -3
- package/dist/src/builtin/index.d.ts +0 -1
- package/dist/src/builtin/interface.d.ts +3 -4
- package/dist/src/builtin/specialExpressionTypes.d.ts +0 -1
- package/dist/src/builtin/specialExpressions/and.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/array.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/block.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/cond.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/if.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/loop.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/loops.d.ts +4 -4
- package/dist/src/builtin/specialExpressions/object.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/or.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/qq.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/recur.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/switch.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/throw.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/try.d.ts +2 -2
- package/dist/src/builtin/specialExpressions/unless.d.ts +2 -2
- package/dist/src/builtin/utils.d.ts +2 -2
- package/dist/src/evaluator/index.d.ts +2 -2
- package/dist/src/evaluator/interface.d.ts +4 -3
- package/dist/src/getUndefinedSymbols/index.d.ts +2 -2
- package/dist/src/parser/ParserContext.d.ts +20 -0
- package/dist/src/parser/helpers.d.ts +19 -0
- package/dist/src/parser/index.d.ts +3 -0
- package/dist/src/parser/subParsers/getPrecedence.d.ts +3 -0
- package/dist/src/parser/subParsers/parseArray.d.ts +3 -0
- package/dist/src/parser/subParsers/parseBindingTarget.d.ts +6 -0
- package/dist/src/parser/subParsers/parseCond.d.ts +4 -0
- package/dist/src/parser/subParsers/parseDo.d.ts +3 -0
- package/dist/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
- package/dist/src/parser/subParsers/parseFunction.d.ts +4 -0
- package/dist/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
- package/dist/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
- package/dist/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
- package/dist/src/parser/subParsers/parseLet.d.ts +4 -0
- package/dist/src/parser/subParsers/parseLoop.d.ts +4 -0
- package/dist/src/parser/subParsers/parseNumber.d.ts +3 -0
- package/dist/src/parser/subParsers/parseObject.d.ts +3 -0
- package/dist/src/parser/subParsers/parseOperand.d.ts +3 -0
- package/dist/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
- package/dist/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
- package/dist/src/parser/subParsers/parseString.d.ts +4 -0
- package/dist/src/parser/subParsers/parseSwitch.d.ts +4 -0
- package/dist/src/parser/subParsers/parseSymbol.d.ts +3 -0
- package/dist/src/parser/subParsers/parseTry.d.ts +4 -0
- package/dist/src/parser/types.d.ts +19 -26
- package/dist/src/testFramework/index.d.ts +3 -2
- package/dist/src/tokenizer/token.d.ts +0 -2
- package/dist/src/tokenizer/tokenizers.d.ts +2 -2
- package/dist/src/typeGuards/astNode.d.ts +18 -19
- package/dist/src/typeGuards/index.d.ts +0 -1
- package/dist/src/typeGuards/lits.d.ts +0 -1
- package/dist/testFramework.esm.js +1 -1
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +1 -1
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/src/parser/Parser.d.ts +0 -58
- package/dist/modules/src/parser/Parser.d.ts +0 -58
- package/dist/src/parser/Parser.d.ts +0 -58
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linear-algebra.esm.js","sources":["../../src/utils/debug/getCodeMarker.ts","../../src/errors.ts","../../src/constants/constants.ts","../../src/utils/debug/debugTools.ts","../../src/utils/symbols.ts","../../src/typeGuards/number.ts","../../src/utils/debug/getSourceCodeInfo.ts","../../src/typeGuards/annotatedArrays.ts","../../src/builtin/modules/vector/calcMean.ts","../../src/builtin/modules/vector/calcMedian.ts","../../src/builtin/modules/vector/calcStdDev.ts","../../src/builtin/modules/vector/calcVariance.ts","../../src/utils/arity.ts","../../src/builtin/modules/linear-algebra/docs.ts","../../src/utils/index.ts","../../src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.ts","../../src/builtin/modules/linear-algebra/helpers/collinear.ts","../../src/builtin/modules/linear-algebra/helpers/isZeroVector.ts","../../src/builtin/modules/linear-algebra/helpers/pearsonCorr.ts","../../src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.ts","../../src/builtin/modules/linear-algebra/helpers/covariance.ts","../../src/builtin/modules/linear-algebra/helpers/getUnit.ts","../../src/builtin/modules/linear-algebra/helpers/dot.ts","../../src/builtin/modules/linear-algebra/helpers/subtract.ts","../../src/builtin/modules/linear-algebra/helpers/scale.ts","../../src/builtin/modules/linear-algebra/index.ts","../../src/builtin/modules/vector/calcMedad.ts","../../src/builtin/modules/linear-algebra/helpers/length.ts","../../src/builtin/modules/linear-algebra/helpers/kendallTau.ts","../../src/builtin/modules/linear-algebra/helpers/corrleation.ts","../../src/builtin/modules/linear-algebra/helpers/solve.ts"],"sourcesContent":["import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getCodeMarker(sourceCodeInfo: SourceCodeInfo): string {\n if (!sourceCodeInfo.position || !sourceCodeInfo.code)\n return ''\n\n const leftPadding = sourceCodeInfo.position.column - 1\n const rightPadding = sourceCodeInfo.code.length - leftPadding - 1\n return `${' '.repeat(Math.max(leftPadding, 0))}^${' '.repeat(Math.max(rightPadding, 0))}`\n}\n","import { getCodeMarker } from '../src/utils/debug/getCodeMarker'\nimport type { Arr } from './interface'\nimport type { SourceCodeInfo } from './tokenizer/token'\n\nfunction getLitsErrorMessage(message: string, sourceCodeInfo?: SourceCodeInfo) {\n if (!sourceCodeInfo) {\n return message\n }\n const location = `${sourceCodeInfo.position.line}:${sourceCodeInfo.position.column}`\n const filePathLine = sourceCodeInfo.filePath\n ? `\\n${sourceCodeInfo.filePath}:${location}`\n : `\\nLocation ${location}`\n const codeLine = `\\n${sourceCodeInfo.code}`\n const codeMarker = `\\n${getCodeMarker(sourceCodeInfo)}`\n return `${message}${filePathLine}${codeLine}${codeMarker}`\n}\n\nexport class RecurSignal extends Error {\n public params: Arr\n constructor(params: Arr) {\n super(`recur, params: ${params}`)\n Object.setPrototypeOf(this, RecurSignal.prototype)\n this.name = 'RecurSignal'\n this.params = params\n }\n}\n\nexport class LitsError extends Error {\n public readonly sourceCodeInfo?: SourceCodeInfo\n public readonly shortMessage: string\n constructor(err: unknown, sourceCodeInfo: SourceCodeInfo | undefined) {\n const message = err instanceof Error\n ? err.message\n : `${err}`\n\n super(getLitsErrorMessage(message, sourceCodeInfo))\n this.shortMessage = message\n this.sourceCodeInfo = sourceCodeInfo\n Object.setPrototypeOf(this, LitsError.prototype)\n this.name = 'LitsError'\n }\n\n public getCodeMarker(): string | undefined {\n return this.sourceCodeInfo && getCodeMarker(this.sourceCodeInfo)\n }\n}\n\nexport class UserDefinedError extends LitsError {\n public userMessage: string\n constructor(message: string, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n this.userMessage = message\n Object.setPrototypeOf(this, UserDefinedError.prototype)\n this.name = 'UserDefinedError'\n }\n}\n\nexport class AssertionError extends LitsError {\n constructor(message: string | Error, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n Object.setPrototypeOf(this, AssertionError.prototype)\n this.name = 'AssertionError'\n }\n}\n\nexport class UndefinedSymbolError extends LitsError {\n public symbol: string\n constructor(symbolName: string, sourceCodeInfo?: SourceCodeInfo) {\n const message = `Undefined symbol '${symbolName}'.`\n super(message, sourceCodeInfo)\n this.symbol = symbolName\n Object.setPrototypeOf(this, UndefinedSymbolError.prototype)\n this.name = 'UndefinedSymbolError'\n }\n}\n\nexport function isLitsError(error: unknown): error is LitsError {\n return error instanceof LitsError\n}\n","export const NodeTypes = {\n Number: 1,\n String: 2,\n NormalExpression: 3,\n SpecialExpression: 4,\n UserDefinedSymbol: 5,\n NormalBuiltinSymbol: 6,\n SpecialBuiltinSymbol: 7,\n ReservedSymbol: 8,\n Binding: 9,\n Spread: 10,\n} as const\n\nconst NodeTypesSet = new Set(Object.values(NodeTypes))\n\nexport type NodeType = typeof NodeTypes[keyof typeof NodeTypes]\n\nexport function getNodeTypeName(type: NodeType): keyof typeof NodeTypes {\n return Object.keys(NodeTypes).find(key => NodeTypes[key as keyof typeof NodeTypes] === type) as keyof typeof NodeTypes\n}\n\n// TODO, is this needed?\nexport function isNodeType(type: unknown): type is NodeType {\n return typeof type === 'number' && NodeTypesSet.has(type as NodeType)\n}\n\nconst functionTypes = [\n 'UserDefined',\n 'Partial',\n 'Comp',\n 'Constantly',\n 'Juxt',\n 'Complement',\n 'EveryPred',\n 'SomePred',\n 'Fnull',\n 'Builtin',\n 'SpecialBuiltin',\n 'NativeJsFunction',\n 'Module',\n] as const\n\nconst functionTypeSet = new Set(functionTypes)\n\nexport type FunctionType = typeof functionTypes[number]\n\nexport function isFunctionType(type: unknown): type is FunctionType {\n return typeof type === 'string' && functionTypeSet.has(type as FunctionType)\n}\n","import { getNodeTypeName, isFunctionType, isNodeType } from '../../constants/constants'\nimport type { LitsFunction, Node } from '../../parser/types'\nimport { FUNCTION_SYMBOL } from '../symbols'\n\nfunction isLitsFunction(func: unknown): func is LitsFunction {\n if (func === null || typeof func !== 'object')\n return false\n\n return FUNCTION_SYMBOL in func && 'functionType' in func && isFunctionType(func.functionType)\n}\n\nfunction isNode(value: unknown): value is Node {\n if (!Array.isArray(value) || value.length < 2)\n return false\n return isNodeType(value[0])\n}\n\nexport function valueToString(value: unknown): string {\n if (isLitsFunction(value))\n // eslint-disable-next-line ts/no-unsafe-member-access\n return `<function ${(value as any).name || '\\u03BB'}>`\n\n if (isNode(value))\n return `${getNodeTypeName(value[0])}-node`\n\n if (value === null)\n return 'null'\n\n if (typeof value === 'object' && value instanceof RegExp)\n return `${value}`\n\n if (typeof value === 'object' && value instanceof Error)\n return value.toString()\n\n return JSON.stringify(value)\n}\n","export const FUNCTION_SYMBOL = '^^fn^^'\nexport const REGEXP_SYMBOL = '^^re^^'\n","import { LitsError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\ntype SignOptions =\n | {\n positive?: true\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: true\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: true\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: true\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: true\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: true\n }\n\ntype GtOptions =\n | {\n gt?: number\n gte?: never\n }\n | {\n gt?: never\n gte?: number\n }\n\ntype LtOptions =\n | {\n lt?: number\n lte?: never\n }\n | {\n lt?: never\n lte?: number\n }\n\ntype NumberOptions = {\n integer?: true\n finite?: true\n} & SignOptions &\nGtOptions &\nLtOptions\n\nfunction getRangeString(options: NumberOptions): string {\n const hasUpperAndLowerBound\n = (typeof options.gt === 'number' || typeof options.gte === 'number')\n && (typeof options.lt === 'number' || typeof options.lte === 'number')\n if (hasUpperAndLowerBound) {\n return `${typeof options.gt === 'number' ? `${options.gt} < n ` : `${options.gte} <= n `}${\n typeof options.lt === 'number' ? `< ${options.lt}` : `<= ${options.lte}`\n }`\n }\n else if (typeof options.gt === 'number' || typeof options.gte === 'number') {\n return `${typeof options.gt === 'number' ? `n > ${options.gt}` : `n >= ${options.gte}`}`\n }\n else if (typeof options.lt === 'number' || typeof options.lte === 'number') {\n return `${typeof options.lt === 'number' ? `n < ${options.lt}` : `n <= ${options.lte}`}`\n }\n else { return '' }\n}\n\nfunction getSignString(options: NumberOptions): string {\n return options.positive\n ? 'positive'\n : options.negative\n ? 'negative'\n : options.nonNegative\n ? 'non negative'\n : options.nonPositive\n ? 'non positive'\n : options.nonZero\n ? 'non zero'\n : ''\n}\n\nfunction getNumberTypeName(options: NumberOptions): string {\n if (options.zero)\n return 'zero'\n\n const sign = getSignString(options)\n const numberType = options.integer ? 'integer' : 'number'\n const finite = options.finite ? 'finite' : ''\n const range = getRangeString(options)\n\n return [sign, finite, numberType, range].filter(x => !!x).join(' ')\n}\n\nexport function isNumber(value: unknown, options: NumberOptions = {}): value is number {\n if (typeof value !== 'number')\n return false\n\n if (Number.isNaN(value))\n return false\n\n if (options.integer && !Number.isInteger(value))\n return false\n\n if (options.finite && !Number.isFinite(value))\n return false\n\n if (options.zero && value !== 0)\n return false\n\n if (options.nonZero && value === 0)\n return false\n\n if (options.positive && value <= 0)\n return false\n\n if (options.negative && value >= 0)\n return false\n\n if (options.nonPositive && value > 0)\n return false\n\n if (options.nonNegative && value < 0)\n return false\n\n if (typeof options.gt === 'number' && value <= options.gt)\n return false\n\n if (typeof options.gte === 'number' && value < options.gte)\n return false\n\n if (typeof options.lt === 'number' && value >= options.lt)\n return false\n\n if (typeof options.lte === 'number' && value > options.lte)\n return false\n\n return true\n}\n\nexport function assertNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n options: NumberOptions = {},\n): asserts value is number {\n if (!isNumber(value, options)) {\n throw new LitsError(\n `Expected ${getNumberTypeName(options)}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asNumber(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: NumberOptions = {},\n): number {\n assertNumber(value, sourceCodeInfo, options)\n return value\n}\n","import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getSourceCodeInfo(anyValue: any, sourceCodeInfo: SourceCodeInfo | undefined): SourceCodeInfo | undefined {\n // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access\n return anyValue?.sourceCodeInfo ?? sourceCodeInfo\n}\n","import { LitsError } from '../errors'\nimport type { Any } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isNumber } from './number'\n\nconst annotatedArrays = new WeakSet<unknown[]>()\nconst vectors = new WeakSet<unknown[]>()\nconst notVectors = new WeakSet<unknown[]>()\nconst matrices = new WeakSet<unknown[]>()\nconst notMatrices = new WeakSet<unknown[]>()\nconst grids = new WeakSet<unknown[]>()\nconst notGrids = new WeakSet<unknown[]>()\n\nexport function annotate<T>(value: T): T {\n if (!Array.isArray(value)) {\n return value\n }\n if (annotatedArrays.has(value)) {\n return value\n }\n isVector(value)\n if (!isMatrix(value)) {\n isGrid(value)\n }\n\n return value\n}\nexport function isVector(vector: unknown): vector is number[] {\n if (!Array.isArray(vector)) {\n return false\n }\n\n if (vectors.has(vector)) {\n return true\n }\n if (notVectors.has(vector)) {\n return false\n }\n\n if (vector.every(elem => isNumber(elem))) {\n annotatedArrays.add(vector)\n vectors.add(vector)\n return true\n }\n notVectors.add(vector)\n return false\n}\n\nexport function assertVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n if (!isVector(vector)) {\n throw new LitsError(`Expected a vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is2dVector(vector: unknown): vector is [number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 2\n}\nexport function assert2dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number] {\n if (!is2dVector(vector)) {\n throw new LitsError(`Expected a 2d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is3dVector(vector: unknown): vector is [number, number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 3\n}\nexport function assert3dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number, number] {\n if (!is3dVector(vector)) {\n throw new LitsError(`Expected a 3d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function assertNonEmptyVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n assertVector(vector, sourceCodeInfo)\n if (vector.length === 0) {\n throw new LitsError(`Expected a non empty vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function isGrid(grid: unknown): grid is unknown[][] {\n if (!Array.isArray(grid)) {\n return false\n }\n if (grids.has(grid)) {\n return true\n }\n if (notGrids.has(grid)) {\n return false\n }\n if (grid.length === 0) {\n notGrids.add(grid)\n return false\n }\n if (!Array.isArray(grid[0])) {\n notGrids.add(grid)\n return false\n }\n const nbrOfCols = grid[0].length\n for (const row of grid.slice(1)) {\n if (!Array.isArray(row)) {\n notGrids.add(grid)\n return false\n }\n if (row.length !== nbrOfCols) {\n notGrids.add(grid)\n return false\n }\n }\n annotatedArrays.add(grid)\n grids.add(grid)\n return true\n}\n\nexport function assertGrid(grid: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts grid is Any[][] {\n if (!isGrid(grid)) {\n throw new LitsError(`Expected a grid, but got ${grid}`, sourceCodeInfo)\n }\n}\n\nexport function isMatrix(matrix: unknown): matrix is number[][] {\n if (!Array.isArray(matrix)) {\n return false\n }\n if (matrices.has(matrix)) {\n return true\n }\n if (notMatrices.has(matrix)) {\n return false\n }\n if (matrix.length === 0) {\n notMatrices.add(matrix)\n return false\n }\n if (!Array.isArray(matrix[0]) || matrix[0].length === 0) {\n notMatrices.add(matrix)\n return false\n }\n const nbrOfCols = matrix[0].length\n for (const row of matrix) {\n if (!Array.isArray(row) || row.length !== nbrOfCols || row.some(cell => !isNumber(cell))) {\n notMatrices.add(matrix)\n return false\n }\n }\n annotatedArrays.add(matrix)\n grids.add(matrix)\n matrices.add(matrix)\n return true\n}\n\nexport function assertMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new LitsError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n}\n\nexport function assertSquareMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new LitsError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n if (matrix.length !== matrix[0]!.length) {\n throw new LitsError(`Expected square matrix, but got ${matrix.length} and ${matrix[0]!.length}`, sourceCodeInfo)\n }\n}\n\nexport function isSquareMatrix(matrix: unknown): matrix is number[][] {\n if (!isMatrix(matrix)) {\n return false\n }\n if (matrix.length !== matrix[0]!.length) {\n return false\n }\n return true\n}\n","export function calcMean(vector: number[]): number {\n if (vector.length === 0) {\n return 0\n }\n\n const sum = vector.reduce((acc, val) => acc + val, 0)\n return sum / vector.length\n}\n","export function calcMedian(vector: number[]): number {\n const sorted = [...vector].sort((a, b) => a - b)\n const mid = Math.floor(sorted.length / 2)\n\n return sorted.length % 2 === 0\n ? (sorted[mid - 1]! + sorted[mid]!) / 2\n : sorted[mid]!\n}\n","import { calcVariance } from './calcVariance'\n\nexport function calcStdDev(vector: number[], optionalMean?: number): number {\n const variance = calcVariance(vector, optionalMean)\n return Math.sqrt(variance)\n}\n\nexport function calcSampleStdDev(vector: number[], optionalMean?: number): number {\n const variance = calcVariance(vector, optionalMean)\n return Math.sqrt(variance * (vector.length / (vector.length - 1)))\n}\n","import { calcMean } from './calcMean'\n\nexport function calcVariance(vector: number[], optionalMean?: number): number {\n const mean = optionalMean ?? calcMean(vector)\n return vector.reduce((acc, val) => acc + (val - mean) ** 2, 0) / vector.length\n}\n\nexport function calcSampleVariance(vector: number[], optionalMean?: number): number {\n const mean = optionalMean ?? calcMean(vector)\n return vector.reduce((acc, val) => acc + (val - mean) ** 2, 0) / (vector.length - 1)\n}\n","import type { Arity } from '../builtin/interface'\nimport { LitsError } from '../errors'\nimport type { FunctionLike } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isColl } from '../typeGuards/lits'\nimport { valueToString } from './debug/debugTools'\n\nexport function arityAccepts(arity: Arity, nbrOfParams: number): boolean {\n const { min, max } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n if (typeof max === 'number' && nbrOfParams > max) {\n return false\n }\n return true\n}\n\nexport function arityAcceptsMin(arity: Arity, nbrOfParams: number): boolean {\n const { min } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n return true\n}\n\nexport function getCommonArityFromFunctions(params: FunctionLike[]): Arity | null {\n return params.reduce((acc: Arity | null, param): Arity | null => {\n if (acc === null) {\n return null\n }\n const arity: Arity = (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n const { min: aMin, max: aMax } = arity\n const { min: bMin, max: bMax } = acc\n const min = typeof aMin === 'number' && typeof bMin === 'number'\n ? Math.max(aMin, bMin)\n : typeof aMin === 'number' ? aMin : typeof bMin === 'number' ? bMin : undefined\n const max = typeof aMax === 'number' && typeof bMax === 'number'\n ? Math.min(aMax, bMax)\n : typeof aMax === 'number' ? aMax : typeof bMax === 'number' ? bMax : undefined\n\n if (typeof min === 'number' && typeof max === 'number' && min > max) {\n return null\n }\n\n return { min, max }\n }, {})\n}\n\nexport function getArityFromFunction(param: FunctionLike): Arity {\n return (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n}\n\nexport function assertNumberOfParams(arity: Arity, length: number, sourceCodeInfo: SourceCodeInfo | undefined): void {\n const { min, max } = arity\n if (typeof min === 'number' && length < min) {\n throw new LitsError(\n `Wrong number of arguments, expected at least ${min}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n\n if (typeof max === 'number' && length > max) {\n throw new LitsError(\n `Wrong number of arguments, expected at most ${max}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n}\n\nexport function canBeOperator(count: Arity): boolean {\n if (typeof count.max === 'number' && count.max < 2) {\n return false\n }\n\n if (typeof count.min === 'number' && count.min > 2) {\n return false\n }\n\n return true\n}\n\nexport function toFixedArity(arity: number): Arity {\n return { min: arity, max: arity }\n}\n","import type { FunctionDocs } from '../../interface'\n\nexport const moduleDocs: Record<string, FunctionDocs> = {\n 'reflect': {\n category: 'linear-algebra',\n description: 'Reflects a vector across a given axis.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to reflect.',\n },\n b: {\n type: 'vector',\n description: 'Axis of reflection.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { reflect } = import(\"linear-algebra\");\\nreflect([1, 2], [0, 1])',\n 'let { reflect } = import(\"linear-algebra\");\\nreflect([1, 2, 3], [0, 0, 1])',\n ],\n seeAlso: ['linear-algebra.refract', 'linear-algebra.projection'],\n },\n 'refract': {\n category: 'linear-algebra',\n description: 'Refracts a vector across a given axis.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Vector to refract.',\n },\n axis: {\n type: 'vector',\n description: 'Axis of refraction.',\n },\n eta: {\n type: 'number',\n description: 'Refraction index.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'axis',\n 'eta',\n ],\n },\n ],\n examples: [\n 'let { refract } = import(\"linear-algebra\");\\nrefract([1, 2], [0, 1], 1.5)',\n 'let { refract } = import(\"linear-algebra\");\\nrefract([1, 2, 3], [0, 0, 1], 1.5)',\n ],\n seeAlso: ['linear-algebra.reflect'],\n },\n 'lerp': {\n category: 'linear-algebra',\n description: 'Performs linear interpolation between two vectors.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Start vector.',\n },\n b: {\n type: 'vector',\n description: 'End vector.',\n },\n t: {\n type: 'number',\n description: 'Interpolation factor (0 to 1).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n 't',\n ],\n },\n ],\n examples: [\n 'let { lerp } = import(\"linear-algebra\");\\nlerp([1, 2], [3, 4], 0.5)',\n 'let { lerp } = import(\"linear-algebra\");\\nlerp([1, 2], [3, 4], 2)',\n 'let { lerp } = import(\"linear-algebra\");\\nlerp([1, 2], [3, 4], -1)',\n 'let { lerp } = import(\"linear-algebra\");\\nlerp([1, 2, 3], [4, 5, 6], 0.25)',\n ],\n seeAlso: ['linear-algebra.projection'],\n },\n 'rotate2d': {\n category: 'linear-algebra',\n description: 'Rotates a 2D vector by a given angle in radians.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to rotate.',\n },\n b: {\n type: 'number',\n description: 'Angle in b.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { rotate2d } = import(\"linear-algebra\");\\nrotate2d([1, 0], PI / 2)',\n 'let { rotate2d } = import(\"linear-algebra\");\\nrotate2d([0, 1], PI)',\n ],\n seeAlso: ['linear-algebra.rotate3d', 'linear-algebra.angle'],\n },\n 'rotate3d': {\n category: 'linear-algebra',\n description: 'Rotates a 3D vector around a given axis by a given angle in radians.',\n returns: {\n type: 'vector',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to rotate.',\n },\n axis: {\n type: 'vector',\n description: 'Axis of rotation.',\n },\n radians: {\n type: 'number',\n description: 'Angle in radians.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n 'axis',\n 'radians',\n ],\n },\n ],\n examples: [\n 'let { rotate3d } = import(\"linear-algebra\");\\nrotate3d([1, 0, 0], [0, 1, 0], PI / 2)',\n 'let { rotate3d } = import(\"linear-algebra\");\\nrotate3d([0, 1, 0], [1, 0, 0], PI)',\n ],\n seeAlso: ['linear-algebra.rotate2d', 'linear-algebra.angle'],\n },\n 'dot': {\n category: 'linear-algebra',\n description: 'Calculates the dot product of two vectors. The result is a scalar.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'First vector.',\n },\n b: {\n type: 'vector',\n description: 'Second vector.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { dot } = import(\"linear-algebra\");\\ndot([1, 2], [3, 4])',\n 'let { dot } = import(\"linear-algebra\");\\ndot([1, 2, 3], [4, 5, 6])',\n ],\n seeAlso: ['linear-algebra.cross', 'linear-algebra.cosine-similarity', 'linear-algebra.angle', 'linear-algebra.projection', 'linear-algebra.orthogonal?'],\n },\n 'cross': {\n category: 'linear-algebra',\n description: 'Calculates the cross product of two 3D vectors. The result is a vector perpendicular to both input vectors.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'First vector (3D).',\n },\n b: {\n type: 'vector',\n description: 'Second vector (3D).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cross } = import(\"linear-algebra\");\\ncross([1, 2, 3], [4, 5, 6])',\n 'let { cross } = import(\"linear-algebra\");\\ncross([1, 0, 0], [0, 1, 0])',\n 'let { cross } = import(\"linear-algebra\");\\ncross([0, 0, 1], [1, 0, 0])',\n 'let { cross } = import(\"linear-algebra\");\\ncross([1, 2, 3], [0, 0, 0])',\n 'let { cross } = import(\"linear-algebra\");\\ncross([0, 0, 0], [1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.dot'],\n },\n 'normalize-minmax': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using min-max normalization. The result is a vector with values between 0 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, 3])',\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, -3])',\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, 3, 4])',\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, -3, 4])',\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-zscore', 'linear-algebra.normalize-robust', 'linear-algebra.normalize-l1', 'linear-algebra.normalize-l2', 'linear-algebra.normalize-log'],\n },\n 'normalize-zscore': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using z-score normalization. The result is a vector with mean 0 and standard deviation 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, 3])',\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, -3])',\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, 3, 4])',\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, -3, 4])',\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-minmax', 'linear-algebra.normalize-robust', 'linear-algebra.normalize-l1', 'linear-algebra.normalize-l2', 'linear-algebra.normalize-log'],\n },\n 'normalize-robust': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using robust normalization. The result is a vector with median 0 and median absolute deviation 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, 3])',\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, -3])',\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, 3, 4])',\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, -3, 4])',\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-minmax', 'linear-algebra.normalize-zscore'],\n },\n 'normalize-l1': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using L1 normalization. The result is a vector with L1 norm equal to 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, 3])',\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, -3])',\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, 3, 4])',\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, -3, 4])',\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-l2', 'linear-algebra.normalize-minmax', 'linear-algebra.manhattan-norm', 'linear-algebra.normalize-zscore'],\n },\n 'normalize-l2': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using L2 normalization. The result is a vector with L2 norm equal to 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, 3])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, 3])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, -3])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, 3, 4])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, -3, 4])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-l1', 'linear-algebra.normalize-minmax', 'linear-algebra.euclidean-norm', 'linear-algebra.normalize-zscore'],\n },\n 'normalize-log': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using natural log normalization. The result is a vector with log-transformed values.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-log } = import(\"linear-algebra\");\\nnormalize-log([1, 2, 3])',\n 'let { normalize-log } = import(\"linear-algebra\");\\nnormalize-log([1, 2, 3, 4])',\n 'let { normalize-log } = import(\"linear-algebra\");\\nnormalize-log([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-minmax', 'linear-algebra.normalize-zscore'],\n },\n 'angle': {\n category: 'linear-algebra',\n description: 'Calculates the **angle** between two vectors in radians.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { angle } = import(\"linear-algebra\");\\nangle([1, 0], [0, 1])',\n 'let { angle } = import(\"linear-algebra\");\\nangle([1, 0, 1], [0, 1, 0])',\n ],\n seeAlso: ['linear-algebra.dot', 'linear-algebra.collinear?', 'linear-algebra.orthogonal?', 'linear-algebra.rotate2d', 'linear-algebra.rotate3d', 'linear-algebra.parallel?', 'linear-algebra.cosine-similarity', 'linear-algebra.to-polar'],\n },\n 'projection': {\n category: 'linear-algebra',\n description: 'Calculates the **projection** of vector `a` onto vector `b`.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { projection } = import(\"linear-algebra\");\\nprojection([1, 2], [3, 4])',\n 'let { projection } = import(\"linear-algebra\");\\nprojection([1, 2, 3], [4, 5, 6])',\n ],\n seeAlso: ['linear-algebra.dot', 'linear-algebra.reflect', 'linear-algebra.lerp'],\n },\n 'collinear?': {\n category: 'linear-algebra',\n description: 'Checks if two vectors are **collinear**.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { collinear? } = import(\"linear-algebra\");\\ncollinear?([1, 2], [2, 4])',\n 'let { collinear? } = import(\"linear-algebra\");\\ncollinear?([1, 2], [-2, -4])',\n 'let { collinear? } = import(\"linear-algebra\");\\ncollinear?([1, 2, 3], [2, 4, 6])',\n ],\n seeAlso: ['linear-algebra.parallel?', 'linear-algebra.orthogonal?', 'linear-algebra.angle'],\n },\n 'parallel?': {\n category: 'linear-algebra',\n description: 'Checks if two vectors are **parallel**.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { parallel? } = import(\"linear-algebra\");\\nparallel?([1, 2], [2, 4])',\n 'let { parallel? } = import(\"linear-algebra\");\\nparallel?([1, 2], [-2, -4])',\n 'let { parallel? } = import(\"linear-algebra\");\\nparallel?([1, 2, 3], [2, 4, 6])',\n 'let { parallel? } = import(\"linear-algebra\");\\nparallel?([1, 2], [3, 4])',\n ],\n seeAlso: ['linear-algebra.collinear?', 'linear-algebra.orthogonal?', 'linear-algebra.angle'],\n },\n 'orthogonal?': {\n category: 'linear-algebra',\n description: 'Checks if two vectors are **orthogonal**.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { orthogonal? } = import(\"linear-algebra\");\\northogonal?([1, 0], [0, 1])',\n 'let { orthogonal? } = import(\"linear-algebra\");\\northogonal?([1, 0, 1], [0, 1, 0])',\n 'let { orthogonal? } = import(\"linear-algebra\");\\northogonal?([1, 2], [2, -1])',\n ],\n seeAlso: ['linear-algebra.collinear?', 'linear-algebra.parallel?', 'linear-algebra.dot', 'matrix.orthogonal?', 'linear-algebra.angle'],\n },\n 'cosine-similarity': {\n category: 'linear-algebra',\n description: 'Calculates the **cosine similarity** between two vectors. The result is a value between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cosine-similarity } = import(\"linear-algebra\");\\ncosine-similarity([1, 2], [3, 4])',\n 'let { cosine-similarity } = import(\"linear-algebra\");\\ncosine-similarity([1, 2, 3], [4, 5, 6])',\n 'let { cosine-similarity } = import(\"linear-algebra\");\\ncosine-similarity([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.dot', 'linear-algebra.angle', 'linear-algebra.euclidean-distance'],\n },\n 'euclidean-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Euclidean distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { euclidean-distance } = import(\"linear-algebra\");\\neuclidean-distance([1, 2], [3, 4])',\n 'let { euclidean-distance } = import(\"linear-algebra\");\\neuclidean-distance([1, 2, 3], [4, 5, 6])',\n 'let { euclidean-distance } = import(\"linear-algebra\");\\neuclidean-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.manhattan-distance', 'linear-algebra.chebyshev-distance', 'linear-algebra.minkowski-distance', 'linear-algebra.euclidean-norm', 'linear-algebra.cosine-similarity', 'linear-algebra.hamming-distance'],\n },\n 'euclidean-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Euclidean norm** (L2 norm) of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { euclidean-norm } = import(\"linear-algebra\");\\neuclidean-norm([1, 2])',\n 'let { euclidean-norm } = import(\"linear-algebra\");\\neuclidean-norm([3, 4])',\n 'let { euclidean-norm } = import(\"linear-algebra\");\\neuclidean-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.manhattan-norm', 'linear-algebra.chebyshev-norm', 'linear-algebra.minkowski-norm', 'linear-algebra.euclidean-distance', 'linear-algebra.normalize-l2', 'linear-algebra.hamming-norm'],\n },\n 'manhattan-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Manhattan distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { manhattan-distance } = import(\"linear-algebra\");\\nmanhattan-distance([1, 2], [3, 4])',\n 'let { manhattan-distance } = import(\"linear-algebra\");\\nmanhattan-distance([1, 2, 3], [4, 5, 6])',\n 'let { manhattan-distance } = import(\"linear-algebra\");\\nmanhattan-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.chebyshev-distance', 'linear-algebra.minkowski-distance', 'linear-algebra.manhattan-norm', 'linear-algebra.hamming-distance'],\n },\n 'manhattan-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Manhattan norm** (L1 norm) of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { manhattan-norm } = import(\"linear-algebra\");\\nmanhattan-norm([1, 2])',\n 'let { manhattan-norm } = import(\"linear-algebra\");\\nmanhattan-norm([3, 4])',\n 'let { manhattan-norm } = import(\"linear-algebra\");\\nmanhattan-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.chebyshev-norm', 'linear-algebra.minkowski-norm', 'linear-algebra.manhattan-distance', 'linear-algebra.normalize-l1', 'linear-algebra.hamming-norm'],\n },\n 'hamming-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Hamming distance** between two vectors. The result is a non-negative integer.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { hamming-distance } = import(\"linear-algebra\");\\nhamming-distance([1, 2], [3, 4])',\n 'let { hamming-distance } = import(\"linear-algebra\");\\nhamming-distance([1, 2, 3], [4, 5, 6])',\n 'let { hamming-distance } = import(\"linear-algebra\");\\nhamming-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.manhattan-distance', 'linear-algebra.hamming-norm'],\n },\n 'hamming-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Hamming norm** of a vector. The result is a non-negative integer.',\n returns: {\n type: 'integer',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { hamming-norm } = import(\"linear-algebra\");\\nhamming-norm([1, 2])',\n 'let { hamming-norm } = import(\"linear-algebra\");\\nhamming-norm([3, 4])',\n 'let { hamming-norm } = import(\"linear-algebra\");\\nhamming-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.manhattan-norm', 'linear-algebra.hamming-distance'],\n },\n 'chebyshev-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Chebyshev distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { chebyshev-distance } = import(\"linear-algebra\");\\nchebyshev-distance([1, 2], [3, 4])',\n 'let { chebyshev-distance } = import(\"linear-algebra\");\\nchebyshev-distance([1, 2, 3], [4, 5, 6])',\n 'let { chebyshev-distance } = import(\"linear-algebra\");\\nchebyshev-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.manhattan-distance', 'linear-algebra.minkowski-distance', 'linear-algebra.chebyshev-norm'],\n },\n 'chebyshev-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Chebyshev norm** of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { chebyshev-norm } = import(\"linear-algebra\");\\nchebyshev-norm([1, 2])',\n 'let { chebyshev-norm } = import(\"linear-algebra\");\\nchebyshev-norm([3, 4])',\n 'let { chebyshev-norm } = import(\"linear-algebra\");\\nchebyshev-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.manhattan-norm', 'linear-algebra.minkowski-norm', 'linear-algebra.chebyshev-distance'],\n },\n 'minkowski-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Minkowski distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n p: {\n type: 'number',\n description: 'Order of the norm (p).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n 'p',\n ],\n },\n ],\n examples: [\n 'let { minkowski-distance } = import(\"linear-algebra\");\\nminkowski-distance([1, 2], [3, 4], 2)',\n 'let { minkowski-distance } = import(\"linear-algebra\");\\nminkowski-distance([1, 2, 3], [4, 5, 6], 3)',\n 'let { minkowski-distance } = import(\"linear-algebra\");\\nminkowski-distance([1, 0], [0, 1], 1)',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.manhattan-distance', 'linear-algebra.chebyshev-distance', 'linear-algebra.minkowski-norm'],\n },\n 'minkowski-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Minkowski norm** of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n b: {\n type: 'number',\n description: 'Order of the norm (p).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { minkowski-norm } = import(\"linear-algebra\");\\nminkowski-norm([1, 2], 2)',\n 'let { minkowski-norm } = import(\"linear-algebra\");\\nminkowski-norm([3, 4], 3)',\n 'let { minkowski-norm } = import(\"linear-algebra\");\\nminkowski-norm([1, 2, 3], 4)',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.manhattan-norm', 'linear-algebra.chebyshev-norm', 'linear-algebra.minkowski-distance'],\n },\n 'cov': {\n category: 'linear-algebra',\n description: 'Calculates the **covariance** between two vectors. The result is a number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cov } = import(\"linear-algebra\");\\ncov([1, 2], [3, 4])',\n 'let { cov } = import(\"linear-algebra\");\\ncov([1, 2, 3], [4, 5, 6])',\n 'let { cov } = import(\"linear-algebra\");\\ncov([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.corr', 'linear-algebra.pearson-corr', 'vector.variance'],\n },\n 'corr': {\n category: 'linear-algebra',\n description: 'Calculates the **correlation** between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { corr } = import(\"linear-algebra\");\\ncorr([1, 2], [3, 4])',\n 'let { corr } = import(\"linear-algebra\");\\ncorr([1, 2, 3], [4, 5, 6])',\n 'let { corr } = import(\"linear-algebra\");\\ncorr([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.cov', 'linear-algebra.pearson-corr', 'linear-algebra.spearman-corr', 'linear-algebra.kendall-tau', 'linear-algebra.autocorrelation', 'linear-algebra.cross-correlation'],\n },\n 'spearman-corr': {\n category: 'linear-algebra',\n description: 'Calculates the **Spearman rank correlation** between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { spearman-corr } = import(\"linear-algebra\");\\nspearman-corr([1, 2], [3, 4])',\n 'let { spearman-corr } = import(\"linear-algebra\");\\nspearman-corr([1, 2, 3], [4, 5, 6])',\n 'let { spearman-corr } = import(\"linear-algebra\");\\nspearman-corr([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.pearson-corr', 'linear-algebra.kendall-tau', 'linear-algebra.corr'],\n },\n 'pearson-corr': {\n category: 'linear-algebra',\n description: 'Calculates the **Pearson correlation** between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { pearson-corr } = import(\"linear-algebra\");\\npearson-corr([1, 2], [3, 4])',\n 'let { pearson-corr } = import(\"linear-algebra\");\\npearson-corr([1, 2, 3], [4, 5, 6])',\n 'let { pearson-corr } = import(\"linear-algebra\");\\npearson-corr([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.spearman-corr', 'linear-algebra.kendall-tau', 'linear-algebra.corr', 'linear-algebra.cov'],\n },\n 'kendall-tau': {\n category: 'linear-algebra',\n description: 'Calculates the **Kendall Tau** rank correlation coefficient between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { kendall-tau } = import(\"linear-algebra\");\\nkendall-tau([1, 2], [3, 4])',\n 'let { kendall-tau } = import(\"linear-algebra\");\\nkendall-tau([1, 2, 3], [4, 5, 6])',\n 'let { kendall-tau } = import(\"linear-algebra\");\\nkendall-tau([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.spearman-corr', 'linear-algebra.pearson-corr', 'linear-algebra.corr'],\n },\n 'autocorrelation': {\n category: 'linear-algebra',\n description: 'Calculates the **autocorrelation** of a vector. The result is a vector of autocorrelation coefficients.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to calculate the autocorrelation for.',\n },\n b: {\n type: 'integer',\n description: 'Lag value for the autocorrelation.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], -2)',\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], -1)',\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], 0)',\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], 1)',\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], 2)',\n ],\n seeAlso: ['linear-algebra.cross-correlation', 'linear-algebra.corr'],\n },\n 'cross-correlation': {\n category: 'linear-algebra',\n description: 'Calculates the **cross-correlation** between two vectors. The result is a vector of cross-correlation coefficients.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n lag: {\n type: 'integer',\n description: 'Lag value for the cross-correlation.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n 'lag',\n ],\n },\n ],\n examples: [\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], -2)',\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], -1)',\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], 0)',\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], 1)',\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], 2)',\n ],\n seeAlso: ['linear-algebra.autocorrelation', 'linear-algebra.corr'],\n },\n 'rref': {\n category: 'linear-algebra',\n description: 'Calculates the **Reduced Row Echelon Form** (RREF) of a matrix.',\n returns: {\n type: 'matrix',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'Matrix to calculate the RREF for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { rref } = import(\"linear-algebra\");\\nrref([[1, 2], [3, 4]])',\n 'let { rref } = import(\"linear-algebra\");\\nrref([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n 'let { rref } = import(\"linear-algebra\");\\nrref([[1, 2, 3], [7, 8, 9], [4, 5, 7]])',\n ],\n seeAlso: ['linear-algebra.solve', 'matrix.rank'],\n },\n 'solve': {\n category: 'linear-algebra',\n description: 'Solves a system of linear equations represented by a matrix and a vector.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'matrix',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { solve } = import(\"linear-algebra\");\\nsolve([\\n [2, 1, -1, 1], \\n [4, 5, -3, 2], \\n [6, -2, 5, -3], \\n [8, 3, 2, 4]\\n], [5, 10, 2, 17])',\n 'let { solve } = import(\"linear-algebra\"); solve([[2, 0, 0], [3, 1, 0], [4, 5, 6]], [4, 5, 38])',\n 'let { solve } = import(\"linear-algebra\"); solve([[2, 3], [1, -1]], [8, 2])',\n ],\n seeAlso: ['linear-algebra.rref', 'matrix.inv'],\n },\n 'to-polar': {\n category: 'linear-algebra',\n description: 'Converts a 2D vector to polar coordinates.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: '2D Vector to convert.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { to-polar } = import(\"linear-algebra\");\\nto-polar([1, 2])',\n 'let { to-polar } = import(\"linear-algebra\");\\nto-polar([3, 4])',\n ],\n seeAlso: ['linear-algebra.from-polar', 'linear-algebra.angle'],\n },\n 'from-polar': {\n category: 'linear-algebra',\n description: 'Converts polar coordinates to a 2D vector.',\n returns: {\n type: 'vector',\n },\n args: {\n polar: {\n type: 'vector',\n description: 'Polar coordinates to convert.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'polar',\n ],\n },\n ],\n examples: [\n 'let { from-polar } = import(\"linear-algebra\");\\nfrom-polar([1, PI / 4])',\n 'let { from-polar } = import(\"linear-algebra\");\\nfrom-polar([1, 0])',\n 'let { from-polar } = import(\"linear-algebra\");\\nfrom-polar([1, -PI / 2])',\n ],\n seeAlso: ['linear-algebra.to-polar'],\n },\n}\n","import type { Any, Coll, Obj } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asAny, isColl, isObj, isRegularExpression } from '../typeGuards/lits'\nimport { isNumber } from '../typeGuards/number'\nimport { asString, assertStringOrNumber } from '../typeGuards/string'\nimport { isUnknownRecord } from '../typeGuards'\nimport { LitsError } from '../errors'\n\nexport function collHasKey(coll: unknown, key: string | number): boolean {\n if (!isColl(coll))\n return false\n\n if (typeof coll === 'string' || Array.isArray(coll)) {\n if (!isNumber(key, { integer: true }))\n return false\n\n return key >= 0 && key < coll.length\n }\n return !!Object.getOwnPropertyDescriptor(coll, key)\n}\n\nexport function compare<T extends string | number>(a: T, b: T, sourceCodeInfo: SourceCodeInfo | undefined): number {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a < b ? -1 : a > b ? 1 : 0\n }\n if (typeof a === 'number' && typeof b === 'number') {\n return Math.sign((a) - (b))\n }\n throw new LitsError(`Cannot compare values of different types: ${typeof a} and ${typeof b}`, sourceCodeInfo)\n}\n\nexport function deepEqual(a: unknown, b: unknown, sourceCodeInfo?: SourceCodeInfo): boolean {\n if (a === b)\n return true\n\n if (typeof a === 'number' && typeof b === 'number')\n return approxEqual(a, b)\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length)\n return false\n\n for (let i = 0; i < a.length; i += 1) {\n if (!deepEqual(asAny(a[i], sourceCodeInfo), asAny(b[i], sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n }\n if (isRegularExpression(a) && isRegularExpression(b))\n return a.s === b.s && a.f === b.f\n\n if (isUnknownRecord(a) && isUnknownRecord(b)) {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length)\n return false\n\n for (let i = 0; i < aKeys.length; i += 1) {\n const key = asString(aKeys[i], sourceCodeInfo)\n if (!deepEqual(a[key], b[key], sourceCodeInfo))\n return false\n }\n return true\n }\n return false\n}\n\nexport function toNonNegativeInteger(num: number): number {\n return Math.max(0, Math.ceil(num))\n}\n\nexport function toAny(value: unknown): Any {\n return (value ?? null) as Any\n}\n\nfunction clone<T>(value: T): T {\n if (isObj(value)) {\n return Object.entries(value).reduce((result: Obj, entry) => {\n const [key, val] = entry\n result[key] = clone(val)\n return result\n }, {}) as T\n }\n if (Array.isArray(value))\n // eslint-disable-next-line ts/no-unsafe-return\n return value.map(item => clone(item)) as unknown as T\n\n return value\n}\n\nexport function cloneColl<T extends Coll>(value: T): T {\n return clone(value)\n}\n\nexport function joinSets<T>(...results: Set<T>[]): Set<T> {\n const result = new Set<T>()\n for (const symbols of results)\n symbols.forEach(symbol => result.add(symbol))\n\n return result\n}\n\nexport function addToSet<T>(target: Set<T>, source: Set<T>): void {\n source.forEach(symbol => target.add(symbol))\n}\n\nexport const EPSILON = 1e-10\n\nexport function approxEqual(a: number, b: number, epsilon: number = EPSILON): boolean {\n if (a === b) {\n return true\n }\n\n const diff = Math.abs(a - b)\n\n if (a === 0 || b === 0 || diff < epsilon) {\n // Use absolute error for values near zero\n return diff < epsilon\n }\n const absA = Math.abs(a)\n const absB = Math.abs(b)\n\n // Use relative error for larger values\n return diff / (absA + absB) < epsilon\n}\n\nexport function approxZero(value: number): boolean {\n return Math.abs(value) < EPSILON\n}\n\nexport function smartTrim(str: string, minIndent = 0): string {\n const lines = str.split('\\n')\n while (lines[0]?.match(/^\\s*$/)) {\n lines.shift() // Remove leading empty lines\n }\n while (lines[lines.length - 1]?.match(/^\\s*$/)) {\n lines.pop() // Remove trailing empty lines\n }\n const indent = lines.reduce((acc, line) => {\n if (line.match(/^\\s*$/))\n return acc // Skip empty lines\n const lineIndent = line.match(/^\\s*/)![0].length\n return Math.min(acc, lineIndent)\n }, Infinity)\n return lines.map(line => ' '.repeat(minIndent) + line.slice(indent)).join('\\n').trimEnd()\n}\n","import { approxZero } from '../../../../utils'\n\n/**\n * Performs Gauss-Jordan elimination on a matrix, transforming it to reduced row echelon form\n *\n * @param matrix - The input matrix\n * @returns A tuple containing the reduced row echelon form matrix and the rank\n */\nexport function gaussJordanElimination(matrix: number[][]): [number[][], number] {\n // Create a copy of the matrix to avoid modifying the original\n const m = matrix.map(row => [...row])\n const rows = m.length\n const cols = m[0]!.length\n\n let rank = 0\n let rowsProcessed = 0\n\n // Row reduction to reduced row echelon form\n for (let col = 0; col < cols; col++) {\n // Find the pivot\n let pivotRow = -1\n\n for (let row = rowsProcessed; row < rows; row++) {\n if (!approxZero(m[row]![col]!)) {\n pivotRow = row\n break\n }\n }\n\n if (pivotRow === -1)\n continue // No pivot in this column\n\n // Increase rank\n rank += 1\n\n // Swap rows\n if (pivotRow !== rowsProcessed) {\n [m[pivotRow], m[rowsProcessed]] = [m[rowsProcessed]!, m[pivotRow]!]\n }\n\n // Get the pivot value\n const pivotValue = m[rowsProcessed]![col]!\n\n // Normalize the pivot row (always, for RREF)\n for (let j = col; j < cols; j++) {\n m[rowsProcessed]![j]! /= pivotValue\n }\n\n // Eliminate above and below (full Gauss-Jordan)\n for (let row = 0; row < rows; row++) {\n if (row !== rowsProcessed && !approxZero(m[row]![col]!)) {\n const factor = m[row]![col]!\n for (let j = col; j < cols; j++) {\n m[row]![j]! -= factor * m[rowsProcessed]![j]!\n }\n }\n }\n\n rowsProcessed++\n if (rowsProcessed === rows)\n break\n }\n\n return [m, rank]\n}\n","import { approxEqual, approxZero } from '../../../../utils'\n\nexport function areVectorsCollinear(vectorA: number[], vectorB: number[]): boolean {\n // Check if either vector is zero\n const isZeroVector = (vec: number[]): boolean =>\n vec.every(component => approxZero(component))\n\n if (isZeroVector(vectorA) || isZeroVector(vectorB)) {\n return true // Zero vector is technically collinear to all vectors\n }\n\n // Find the first non-zero component in vectorA\n let index = 0\n while (index < vectorA.length && approxZero(vectorA[index]!)) {\n index++\n }\n\n // Calculate the scale factor\n const ratio = vectorB[index]! / vectorA[index]!\n\n // Check if all other components maintain the same ratio\n for (let i = 0; i < vectorA.length; i++) {\n // Skip components where both vectors have (near) zero values\n if (approxZero(vectorA[i]!) && approxZero(vectorB[i]!))\n continue\n\n // If vectorA component is near zero but vectorB is not, vectors are not collinear\n if (approxZero(vectorA[i]!))\n return false\n\n // Check if the ratio is consistent\n if (!approxEqual(vectorB[i]! / vectorA[i]!, ratio)) {\n return false\n }\n }\n\n return true\n}\n\nexport function areVectorsParallel(vectorA: number[], vectorB: number[]): boolean {\n if (!areVectorsCollinear(vectorA, vectorB)) {\n return false\n }\n\n // Then verify they point in the same direction\n // Find first non-zero component in both vectors\n for (let i = 0; i < vectorA.length; i++) {\n if (!approxZero(vectorA[i]!) && !approxZero(vectorB[i]!)) {\n return Math.sign(vectorA[i]!) === Math.sign(vectorB[i]!)\n }\n }\n\n // If we get here, one of the vectors must be zero\n return true\n}\n","import { approxZero } from '../../../../utils'\n\nexport function isZeroVector(vector: number[]): boolean {\n return vector.every(component => approxZero(component))\n}\n","import { calcMean } from '../../vector/calcMean'\n\nexport function pearsonCorr(vectorA: number[], vectorB: number[]): number {\n const meanA = calcMean(vectorA)\n const meanB = calcMean(vectorB)\n\n let sumNumerator = 0\n let sumSquareA = 0\n let sumSquareB = 0\n\n for (let i = 0; i < vectorA.length; i++) {\n const diffA = vectorA[i]! - meanA\n const diffB = vectorB[i]! - meanB\n\n sumNumerator += diffA * diffB\n sumSquareA += diffA * diffA\n sumSquareB += diffB * diffB\n }\n\n // Check if either vector has zero variance\n if (sumSquareA === 0 || sumSquareB === 0) {\n throw new Error('Cannot calculate Pearson correlation coefficient: one of the vectors has zero variance.')\n }\n\n return sumNumerator / (Math.sqrt(sumSquareA) * Math.sqrt(sumSquareB))\n}\n","export function calcFractionalRanks(vector: number[]): number[] {\n // Create array of indices and sort by values\n const indices = [...vector.keys()].sort((a, b) => vector[a]! - vector[b]!)\n\n // Create ranks array (same size as input vector)\n const ranks: number[] = Array.from<number>({ length: vector.length }).fill(0)\n\n // Assign ranks, handling ties properly\n let currentRank = 1\n let i = 0\n while (i < indices.length) {\n const value = vector[indices[i]!]\n let j = i\n\n // Find all indices with the same value\n while (j < indices.length && vector[indices[j]!] === value) {\n j++\n }\n\n // Calculate average rank for ties\n const averageRank = currentRank + (j - i - 1) / 2\n\n // Assign average rank to all tied elements\n for (let k = i; k < j; k++) {\n ranks[indices[k]!] = averageRank\n }\n\n // Update current rank and index\n currentRank += j - i\n i = j\n }\n\n return ranks\n}\n","import { calcMean } from '../../vector/calcMean'\n\n/**\n * Calculate covariance between two segments\n */\nexport function calcCovariance(segmentA: number[], segmentB: number[]): number {\n const meanA = calcMean(segmentA)\n const meanB = calcMean(segmentB)\n\n let sum = 0\n for (let i = 0; i < segmentA.length; i++) {\n sum += (segmentA[i]! - meanA) * (segmentB[i]! - meanB)\n }\n\n return sum / segmentA.length\n}\n","import { LitsError } from '../../../../errors'\nimport type { SourceCodeInfo } from '../../../../tokenizer/token'\nimport { approxZero } from '../../../../utils'\n\nexport function getUnit<T extends number[]>(\n value: T,\n sourceCodeInfo: SourceCodeInfo | undefined,\n): T {\n if (value.length === 0) {\n return value\n }\n const length = Math.sqrt(value.reduce((acc, item) => acc + item ** 2, 0))\n if (approxZero(length)) {\n throw new LitsError('The vector must not be zero', sourceCodeInfo)\n }\n return value.map(item => item / length) as T\n}\n","export function dot(\n vector1: number[],\n vector2: number[],\n): number {\n return vector1.reduce((acc, item, index) => acc + item * vector2[index]!, 0)\n}\n","export function subtract<T extends number[]>(\n vector1: T,\n vector2: T,\n): T {\n return vector1.map((item, index) => item - vector2[index]!) as T\n}\n","export function scale<T extends number[]>(\n vector: T,\n scalar: number,\n): T {\n return vector.map(item => item * scalar) as T\n}\n","import { LitsError } from '../../../errors'\nimport { assert2dVector, assert3dVector, assertMatrix, assertNonEmptyVector, assertSquareMatrix, assertVector } from '../../../typeGuards/annotatedArrays'\nimport { assertNumber } from '../../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport type { LitsModule } from '../interface'\nimport { calcMean } from '../vector/calcMean'\nimport { calcMedad } from '../vector/calcMedad'\nimport { calcMedian } from '../vector/calcMedian'\nimport { calcStdDev } from '../vector/calcStdDev'\nimport { toFixedArity } from '../../../utils/arity'\nimport { moduleDocs } from './docs'\nimport { gaussJordanElimination } from './helpers/gaussJordanElimination'\nimport { solve } from './helpers/solve'\nimport { areVectorsCollinear, areVectorsParallel } from './helpers/collinear'\nimport { isZeroVector } from './helpers/isZeroVector'\nimport { pearsonCorr } from './helpers/pearsonCorr'\nimport { calcFractionalRanks } from './helpers/calcFractionalRanks'\nimport { kendallTau } from './helpers/kendallTau'\nimport { calcCovariance } from './helpers/covariance'\nimport { calcCorrelation, extractOverlappingSegments } from './helpers/corrleation'\nimport { getUnit } from './helpers/getUnit'\nimport { dot } from './helpers/dot'\nimport { subtract } from './helpers/subtract'\nimport { scale } from './helpers/scale'\nimport { length } from './helpers/length'\n\nexport const linearAlgebraNormalExpression: BuiltinNormalExpressions = {\n 'rotate2d': {\n evaluate: ([vector, radians], sourceCodeInfo): number[] => {\n assert2dVector(vector, sourceCodeInfo)\n if (isZeroVector(vector)) {\n return vector\n }\n assertNumber(radians, sourceCodeInfo, { finite: true })\n const cosTheta = Math.cos(radians)\n const sinTheta = Math.sin(radians)\n return [\n vector[0] * cosTheta - vector[1] * sinTheta,\n vector[0] * sinTheta + vector[1] * cosTheta,\n ]\n },\n arity: toFixedArity(2),\n },\n 'rotate3d': {\n evaluate: ([vector, axis, radians], sourceCodeInfo): number[] => {\n assert3dVector(vector, sourceCodeInfo)\n if (isZeroVector(vector)) {\n return vector\n }\n assertNumber(radians, sourceCodeInfo, { finite: true })\n assert3dVector(axis, sourceCodeInfo)\n if (isZeroVector(axis)) {\n throw new LitsError('Rotation axis must not be zero', sourceCodeInfo)\n }\n const cosTheta = Math.cos(radians)\n const sinTheta = Math.sin(radians)\n const [u, v, w] = getUnit(axis, sourceCodeInfo)\n const dotProduct = vector[0] * u + vector[1] * v + vector[2] * w\n return [\n dotProduct * u * (1 - cosTheta) + vector[0] * cosTheta + (-w * vector[1] + v * vector[2]) * sinTheta,\n dotProduct * v * (1 - cosTheta) + vector[1] * cosTheta + (w * vector[0] - u * vector[2]) * sinTheta,\n dotProduct * w * (1 - cosTheta) + vector[2] * cosTheta + (-v * vector[0] + u * vector[1]) * sinTheta,\n ]\n },\n arity: toFixedArity(3),\n },\n 'reflect': {\n evaluate: ([vector, normal], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n assertVector(normal, sourceCodeInfo)\n if (vector.length !== normal.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n if (isZeroVector(normal)) {\n throw new LitsError('Reflection normal must not be zero', sourceCodeInfo)\n }\n if (isZeroVector(vector)) {\n return vector\n }\n const unitNormal = getUnit(normal, sourceCodeInfo)\n const doubleDot = 2 * dot(vector, unitNormal)\n return subtract(vector, scale(unitNormal, doubleDot))\n },\n arity: toFixedArity(2),\n },\n 'refract': {\n evaluate: ([vector, normal, eta], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n assertVector(normal, sourceCodeInfo)\n assertNumber(eta, sourceCodeInfo, { finite: true, positive: true })\n if (vector.length !== normal.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n if (isZeroVector(normal)) {\n throw new LitsError('Refraction normal must not be zero', sourceCodeInfo)\n }\n if (isZeroVector(vector)) {\n return vector\n }\n // Make sure vectors are normalized\n const normalizedV = getUnit(vector, sourceCodeInfo)\n const normalizedNormal = getUnit(normal, sourceCodeInfo)\n\n // Calculate dot product between incident vector and normal\n const dotProduct = dot(normalizedV, normalizedNormal)\n\n // Calculate discriminant\n const discriminant = 1 - eta * eta * (1 - dotProduct * dotProduct)\n\n // Check for total internal reflection\n if (discriminant < 0) {\n return vector // Total internal reflection occurs\n }\n\n // Calculate the refracted vector\n const scaledIncident = scale(normalizedV, eta)\n const scaledNormal = scale(\n normalizedNormal,\n eta * dotProduct + Math.sqrt(discriminant),\n )\n\n return subtract(scaledIncident, scaledNormal)\n },\n arity: toFixedArity(3),\n },\n 'lerp': {\n evaluate: ([vectorA, vectorB, t], sourceCodeInfo): number[] => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n assertNumber(t, sourceCodeInfo, { finite: true })\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n return vectorA.map((val, i) => val + (vectorB[i]! - val) * t)\n },\n arity: toFixedArity(3),\n },\n 'dot': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return dot(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'cross': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number[] => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== 3 || vectorB.length !== 3) {\n throw new LitsError('Cross product is only defined for 3D vectors', sourceCodeInfo)\n }\n\n return [\n vectorA[1]! * vectorB[2]! - vectorA[2]! * vectorB[1]!,\n vectorA[2]! * vectorB[0]! - vectorA[0]! * vectorB[2]!,\n vectorA[0]! * vectorB[1]! - vectorA[1]! * vectorB[0]!,\n ] as number[]\n },\n arity: toFixedArity(2),\n },\n 'normalize-minmax': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n if (vector.length === 0) {\n return []\n }\n\n const min = vector.reduce((acc, val) => (val < acc ? val : acc), vector[0]!)\n const max = vector.reduce((acc, val) => (val > acc ? val : acc), vector[0]!)\n\n if (min === max) {\n return vector.map(() => 0)\n }\n\n return vector.map(val => (val - min) / (max - min))\n },\n arity: toFixedArity(1),\n },\n 'normalize-robust': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n if (vector.length === 0) {\n return []\n }\n\n const median = calcMedian(vector)\n const medad = calcMedad(vector)\n\n if (medad === 0) {\n return vector.map(val => val - median)\n }\n return vector.map(val => (val - median) / medad)\n },\n arity: toFixedArity(1),\n },\n 'normalize-zscore': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n const mean = calcMean(vector)\n const stdDev = calcStdDev(vector)\n\n if (stdDev === 0) {\n return vector.map(() => 0)\n }\n\n return vector.map(val => (val - mean) / stdDev)\n },\n arity: toFixedArity(1),\n },\n 'normalize-l1': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length === 0) {\n return []\n }\n const norm = vector.reduce((acc, val) => acc + Math.abs(val), 0)\n\n if (norm === 0) {\n return vector.map(() => 0)\n }\n\n return vector.map(val => val / norm)\n },\n arity: toFixedArity(1),\n },\n 'normalize-l2': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n return getUnit(vector, sourceCodeInfo)\n },\n arity: toFixedArity(1),\n },\n 'normalize-log': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n if (vector.length === 0) {\n return []\n }\n\n const min = Math.min(...vector)\n\n if (min <= 0) {\n throw new LitsError('Log normalization requires all values to be positive', sourceCodeInfo)\n }\n\n return vector.map(val => Math.log(val / min))\n },\n arity: toFixedArity(1),\n },\n 'angle': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (isZeroVector(vectorA) || isZeroVector(vectorB)) {\n throw new LitsError('Cannot calculate angle with zero-length vector', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n const magnitudeA = Math.sqrt(vectorA.reduce((acc, val) => acc + val * val, 0))\n const magnitudeB = Math.sqrt(vectorB.reduce((acc, val) => acc + val * val, 0))\n\n return Math.acos(dotProduct / (magnitudeA * magnitudeB))\n },\n arity: toFixedArity(2),\n },\n 'projection': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number[] => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (isZeroVector(vectorB)) {\n throw new LitsError('Cannot project onto zero-length vector', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n const magnitudeB = Math.sqrt(vectorB.reduce((acc, val) => acc + val * val, 0))\n\n return vectorB.map(val => (dotProduct / (magnitudeB ** 2)) * val)\n },\n arity: toFixedArity(2),\n },\n 'orthogonal?': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): boolean => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n return dotProduct === 0\n },\n arity: toFixedArity(2),\n },\n 'parallel?': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): boolean => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return areVectorsParallel(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'collinear?': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): boolean => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return areVectorsCollinear(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'cosine-similarity': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (isZeroVector(vectorA) || isZeroVector(vectorB)) {\n throw new LitsError('Cannot calculate cosine similarity with zero-length vector', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n const magnitudeA = Math.sqrt(vectorA.reduce((acc, val) => acc + val * val, 0))\n const magnitudeB = Math.sqrt(vectorB.reduce((acc, val) => acc + val * val, 0))\n\n return dotProduct / (magnitudeA * magnitudeB)\n },\n arity: toFixedArity(2),\n },\n 'euclidean-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return Math.sqrt(vectorA.reduce((acc, val, i) => acc + (val - vectorB[i]!) ** 2, 0))\n },\n arity: toFixedArity(2),\n },\n 'euclidean-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n\n return length(vector)\n },\n arity: toFixedArity(1),\n },\n 'manhattan-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return vectorA.reduce((acc, val, i) => acc + Math.abs(val - vectorB[i]!), 0)\n },\n arity: toFixedArity(2),\n },\n 'manhattan-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n\n return vector.reduce((acc, val) => acc + Math.abs(val), 0)\n },\n arity: toFixedArity(1),\n },\n 'hamming-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return vectorA.reduce((acc, val, i) => acc + (val !== vectorB[i]! ? 1 : 0), 0)\n },\n arity: toFixedArity(2),\n },\n 'hamming-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + (val !== 0 ? 1 : 0), 0)\n },\n arity: toFixedArity(1),\n },\n 'chebyshev-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return Math.max(...vectorA.map((val, i) => Math.abs(val - vectorB[i]!)))\n },\n arity: toFixedArity(2),\n },\n 'chebyshev-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return Math.max(...vector.map(val => Math.abs(val)))\n },\n arity: toFixedArity(1),\n },\n 'minkowski-distance': {\n evaluate: ([vectorA, vectorB, p], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n assertNumber(p, sourceCodeInfo, { finite: true, positive: true })\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return vectorA.reduce((acc, val, i) => acc + Math.abs(val - vectorB[i]!) ** p, 0) ** (1 / p)\n },\n arity: toFixedArity(3),\n },\n 'minkowski-norm': {\n evaluate: ([vector, p], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n assertNumber(p, sourceCodeInfo, { finite: true, positive: true })\n return vector.reduce((acc, val) => acc + Math.abs(val) ** p, 0) ** (1 / p)\n },\n arity: toFixedArity(2),\n },\n 'cov': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n if (vectorA.length === 1) {\n return 0\n }\n\n return calcCovariance(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'corr': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length <= 1) {\n throw new LitsError('Vectors must have at least 2 elements for corr', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const meanA = calcMean(vectorA)\n const meanB = calcMean(vectorB)\n\n const numerator = vectorA.reduce((acc, val, i) => acc + (val - meanA) * (vectorB[i]! - meanB), 0)\n const denominator = Math.sqrt(\n vectorA.reduce((acc, val) => acc + (val - meanA) ** 2, 0) * vectorB.reduce((acc, val) => acc + (val - meanB) ** 2, 0),\n )\n\n return numerator / denominator\n },\n arity: toFixedArity(2),\n },\n 'spearman-corr': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length <= 1) {\n throw new LitsError('Vectors must have at least 2 elements for corr', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const ranksA = calcFractionalRanks(vectorA)\n const ranksB = calcFractionalRanks(vectorB)\n\n try {\n return pearsonCorr(ranksA, ranksB)\n }\n catch (error) {\n throw new LitsError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'pearson-corr': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length <= 1) {\n throw new LitsError('Vectors must have at least 2 elements for pearson-corr', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n try {\n return pearsonCorr(vectorA, vectorB)\n }\n catch (error) {\n throw new LitsError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'kendall-tau': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length < 2) {\n throw new LitsError('Vectors must have at least 2 elements for kendall-tau', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n try {\n return kendallTau(vectorA, vectorB)\n }\n catch (error) {\n throw new LitsError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'autocorrelation': {\n evaluate: ([vector, lag], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length < 2) {\n throw new LitsError('Vector must have at least 2 elements for autocorrelation', sourceCodeInfo)\n }\n\n assertNumber(lag, sourceCodeInfo, {\n integer: true,\n lt: vector.length,\n gt: -vector.length,\n })\n\n // For lag 0, return 1 (a series is perfectly correlated with itself)\n if (lag === 0) {\n return 1\n }\n const absLag = Math.abs(lag)\n const mean = calcMean(vector)\n\n // Calculate the numerator (sum of products of deviations)\n let numerator = 0\n const n = vector.length\n\n // If lag is positive, correlate current with past values\n // If lag is negative, correlate current with future values (same calculation, different interpretation)\n for (let i = 0; i < n - absLag; i++) {\n const currentIndex = lag < 0 ? i + absLag : i\n const laggedIndex = lag < 0 ? i : i + absLag\n\n numerator += (vector[currentIndex]! - mean) * (vector[laggedIndex]! - mean)\n }\n\n // Calculate the denominator (sum of squared deviations)\n let denominator = 0\n for (let i = 0; i < n; i++) {\n denominator += (vector[i]! - mean) ** 2\n }\n\n // Handle edge case of zero variance\n if (denominator === 0) {\n return 0 // Conventional definition\n }\n\n // Return the autocorrelation coefficient\n return numerator / denominator\n },\n arity: toFixedArity(2),\n },\n\n 'cross-correlation': {\n evaluate: ([vectorA, vectorB, lag], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length < 2) {\n throw new LitsError('Vectors must have at least 2 elements', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n assertNumber(lag, sourceCodeInfo, {\n integer: true,\n lt: vectorA.length,\n gt: -vectorA.length,\n })\n\n // For lag 0 between identical vectors, return 1\n if (lag === 0\n && vectorA.length === vectorB.length\n && vectorA.every((v, i) => v === vectorB[i])) {\n return 1\n }\n\n const [segmentA, segmentB] = extractOverlappingSegments(vectorA, vectorB, lag)\n return calcCorrelation(segmentA, segmentB)\n },\n arity: toFixedArity(3),\n },\n 'rref': {\n evaluate: ([matrix], sourceCodeInfo): number[][] => {\n assertMatrix(matrix, sourceCodeInfo)\n\n // Reduced Row Echelon Form (RREF)\n const [rref] = gaussJordanElimination(matrix)\n return rref\n },\n arity: toFixedArity(1),\n },\n 'solve': {\n evaluate: ([matrix, vector], sourceCodeInfo): number[] | null => {\n assertSquareMatrix(matrix, sourceCodeInfo)\n assertVector(vector, sourceCodeInfo)\n if (matrix.length !== vector.length) {\n throw new LitsError(`The number of rows in the matrix must be equal to the length of the vector, but got ${matrix.length} and ${vector.length}`, sourceCodeInfo)\n }\n return solve(matrix, vector)\n },\n arity: toFixedArity(2),\n },\n 'to-polar': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assert2dVector(vector, sourceCodeInfo)\n if (isZeroVector(vector)) {\n return [0, 0]\n }\n const r = Math.sqrt(vector[0] ** 2 + vector[1] ** 2)\n const theta = Math.atan2(vector[1], vector[0])\n return [r, theta]\n },\n arity: toFixedArity(1),\n },\n 'from-polar': {\n evaluate: ([polar], sourceCodeInfo): number[] => {\n assert2dVector(polar, sourceCodeInfo)\n const [r, theta] = polar\n if (r === 0) {\n return [0, 0]\n }\n return [r * Math.cos(theta), r * Math.sin(theta)]\n },\n arity: toFixedArity(1),\n },\n}\n\nfor (const [key, docs] of Object.entries(moduleDocs)) {\n if (linearAlgebraNormalExpression[key])\n linearAlgebraNormalExpression[key].docs = docs\n}\n\nexport const linearAlgebraModule: LitsModule = {\n name: 'linear-algebra',\n functions: linearAlgebraNormalExpression,\n}\n","import { calcMedian } from './calcMedian'\n\nexport function calcMedad(vector: number[]): number {\n const median = calcMedian(vector)\n // Calculate absolute deviations from the median\n const absoluteDeviations = vector.map(val => Math.abs(val - median))\n\n // Calculate the median of the absolute deviations\n const medianOfDeviations = calcMedian(absoluteDeviations)\n const scaleFactor = 1.4826 // Scale factor for robust scaling\n\n return medianOfDeviations * scaleFactor\n}\n","export function length(vector: number[]): number {\n return Math.sqrt(vector.reduce((acc, item) => acc + item ** 2, 0))\n}\n","/**\n * Calculates Kendall's Tau-b rank correlation coefficient between two vectors\n * This implementation handles ties and uses an epsilon value for floating-point comparisons\n *\n * @param vectorA - First vector of numbers\n * @param vectorB - Second vector of numbers\n * @param epsilon - Threshold for considering two values as equal (default: 1e-10)\n * @returns The Kendall's Tau-b correlation coefficient\n */\nexport function kendallTau(vectorA: number[], vectorB: number[], epsilon: number = 1e-10): number {\n let concordant = 0\n let discordant = 0\n let tiesInA = 0\n let tiesInB = 0\n\n // Compare all pairs\n for (let i = 0; i < vectorA.length; i++) {\n for (let j = i + 1; j < vectorA.length; j++) {\n // Calculate differences\n const diffA = vectorA[i]! - vectorA[j]!\n const diffB = vectorB[i]! - vectorB[j]!\n\n // Check for ties using epsilon\n const isTieA = Math.abs(diffA) < epsilon\n const isTieB = Math.abs(diffB) < epsilon\n\n if (isTieA && isTieB) {\n // Tied in both vectors\n continue\n }\n else if (isTieA) {\n // Tied in vector A only\n tiesInA += 1\n }\n else if (isTieB) {\n // Tied in vector B only\n tiesInB += 1\n }\n else if (diffA * diffB > 0) {\n // Concordant pair\n concordant += 1\n }\n else {\n // Discordant pair\n discordant += 1\n }\n }\n }\n\n const n1 = concordant + discordant + tiesInA\n const n2 = concordant + discordant + tiesInB\n\n // Handle edge cases to avoid division by zero\n if (n1 === 0 || n2 === 0) {\n throw new Error('Not enough data to calculate Kendall\\'s Tau')\n }\n\n // Kendall's Tau-b formula\n return (concordant - discordant) / Math.sqrt(n1 * n2)\n}\n","import { calcMean } from '../../vector/calcMean'\nimport { calcStdDev } from '../../vector/calcStdDev'\nimport { calcCovariance } from './covariance'\n\n/**\n * Calculate Pearson correlation between two segments\n */\nexport function calcCorrelation(segmentA: number[], segmentB: number[]): number {\n const meanA = calcMean(segmentA)\n const meanB = calcMean(segmentB)\n\n const stdA = calcStdDev(segmentA, meanA)\n const stdB = calcStdDev(segmentB, meanB)\n\n // Handle zero variance\n if (stdA === 0 || stdB === 0) {\n // If both have zero variance and are the same constant, they're perfectly correlated\n if (stdA === 0 && stdB === 0 && meanA === meanB) {\n return 1\n }\n // Otherwise, no meaningful correlation can be established\n return 0\n }\n\n const covariance = calcCovariance(segmentA, segmentB)\n return covariance / (stdA * stdB)\n}\n\n/**\n * Extract overlapping segments from two vectors based on lag\n */\nexport function extractOverlappingSegments(\n vectorA: number[],\n vectorB: number[],\n lag: number,\n): [number[], number[]] {\n const absLag = Math.abs(lag)\n const overlapLength = vectorA.length - absLag\n\n let segmentA = []\n let segmentB = []\n\n if (lag >= 0) {\n segmentA = vectorA.slice(0, overlapLength)\n segmentB = vectorB.slice(lag, lag + overlapLength)\n }\n else {\n segmentA = vectorA.slice(absLag)\n segmentB = vectorB.slice(0, overlapLength)\n }\n\n return [segmentA, segmentB]\n}\n","import { approxZero } from '../../../../utils'\nimport { gaussJordanElimination } from './gaussJordanElimination'\n\n/**\n * Solves a system of linear equations Ax = b\n *\n * @param A - The coefficient matrix\n * @param b - The constant vector\n * @returns The solution vector x, or null if no unique solution exists\n */\nexport function solve(A: number[][], b: number[]): number[] | null {\n const n = A.length\n\n // Create augmented matrix [A|b]\n const augmented = A.map((row, i) => [...row, b[i]!])\n\n // Convert to row echelon form using your existing function\n const [echelon] = gaussJordanElimination(augmented)\n\n // Check if the system has a unique solution\n for (let i = 0; i < n; i += 1) {\n if (approxZero(echelon[i]![i]!)) {\n return null // No unique solution\n }\n }\n\n // Back substitution\n const x = Array.from({ length: n }, () => 0)\n for (let i = n - 1; i >= 0; i--) {\n let sum = 0\n for (let j = i + 1; j < n; j++) {\n sum += echelon[i]![j]! * x[j]!\n }\n x[i] = (echelon[i]![n]! - sum) / echelon[i]![i]!\n }\n\n return x\n}\n"],"names":["getCodeMarker","sourceCodeInfo","position","code","leftPadding","column","rightPadding","length","repeat","Math","max","LitsError","Error","shortMessage","constructor","err","message","super","location","line","filePath","getLitsErrorMessage","this","Object","setPrototypeOf","prototype","name","NodeTypes","Number","String","NormalExpression","SpecialExpression","UserDefinedSymbol","NormalBuiltinSymbol","SpecialBuiltinSymbol","ReservedSymbol","Binding","Spread","NodeTypesSet","Set","values","functionTypeSet","isLitsFunction","func","type","functionType","has","isNode","value","Array","isArray","valueToString","keys","find","key","RegExp","toString","JSON","stringify","isNumber","options","isNaN","integer","isInteger","finite","isFinite","zero","nonZero","positive","negative","nonPositive","nonNegative","gt","gte","lt","lte","assertNumber","sign","getSignString","numberType","range","getRangeString","filter","x","join","getNumberTypeName","anyValue","getSourceCodeInfo","annotatedArrays","WeakSet","vectors","notVectors","matrices","notMatrices","grids","isVector","vector","every","elem","add","assertVector","assert2dVector","is2dVector","assert3dVector","is3dVector","assertNonEmptyVector","isMatrix","matrix","nbrOfCols","row","some","cell","calcMean","reduce","acc","val","calcMedian","sorted","sort","a","b","mid","floor","calcStdDev","optionalMean","variance","mean","calcVariance","sqrt","toFixedArity","arity","min","moduleDocs","reflect","category","description","returns","args","variants","argumentNames","examples","seeAlso","refract","axis","eta","lerp","t","rotate2d","rotate3d","v","radians","dot","cross","angle","projection","p","cov","corr","autocorrelation","lag","rref","m","solve","polar","approxEqual","epsilon","diff","abs","approxZero","gaussJordanElimination","map","rows","cols","rank","rowsProcessed","col","pivotRow","pivotValue","j","factor","areVectorsCollinear","vectorA","vectorB","isZeroVector","vec","component","index","ratio","i","pearsonCorr","meanA","meanB","sumNumerator","sumSquareA","sumSquareB","diffA","diffB","calcFractionalRanks","indices","ranks","from","fill","currentRank","averageRank","k","calcCovariance","segmentA","segmentB","sum","getUnit","item","vector1","vector2","subtract","scale","scalar","linearAlgebraNormalExpression","evaluate","cosTheta","cos","sinTheta","sin","u","w","dotProduct","normal","unitNormal","normalizedV","normalizedNormal","discriminant","median","medad","calcMedad","stdDev","norm","log","magnitudeA","magnitudeB","acos","areVectorsParallel","ranksA","ranksB","error","concordant","discordant","tiesInA","tiesInB","isTieA","isTieB","n1","n2","kendallTau","absLag","numerator","n","laggedIndex","denominator","overlapLength","slice","extractOverlappingSegments","stdA","stdB","calcCorrelation","assertMatrix","assertSquareMatrix","A","augmented","echelon","atan2","r","theta","docs","entries","linearAlgebraModule","functions"],"mappings":"AAEM,SAAUA,EAAcC,GAC5B,IAAKA,EAAeC,WAAaD,EAAeE,KAC9C,MAAO,GAET,MAAMC,EAAcH,EAAeC,SAASG,OAAS,EAC/CC,EAAeL,EAAeE,KAAKI,OAASH,EAAc,EAChE,MAAO,GAAG,IAAII,OAAOC,KAAKC,IAAIN,EAAa,OAAO,IAAII,OAAOC,KAAKC,IAAIJ,EAAc,KACtF,CCkBM,MAAOK,UAAkBC,MACbX,eACAY,aAChB,WAAAC,CAAYC,EAAcd,GACxB,MAAMe,EAAUD,aAAeH,MAC3BG,EAAIC,QACJ,GAAGD,IAEPE,MA/BJ,SAA6BD,EAAiBf,GAC5C,IAAKA,EACH,OAAOe,EAET,MAAME,EAAW,GAAGjB,EAAeC,SAASiB,QAAQlB,EAAeC,SAASG,SAM5E,MAAO,GAAGW,IALWf,EAAemB,SAChC,KAAKnB,EAAemB,YAAYF,IAChC,cAAcA,QACIjB,EAAeE,SACbH,EAAcC,IAExC,CAoBUoB,CAAoBL,EAASf,IACnCqB,KAAKT,aAAeG,EACpBM,KAAKrB,eAAiBA,EACtBsB,OAAOC,eAAeF,KAAMX,EAAUc,WACtCH,KAAKI,KAAO,WACb,CAEM,aAAA1B,GACL,OAAOsB,KAAKrB,gBAAkBD,EAAcsB,KAAKrB,eAClD,EC5CI,MAAM0B,EAAY,CACvBC,OAAQ,EACRC,OAAQ,EACRC,iBAAkB,EAClBC,kBAAmB,EACnBC,kBAAmB,EACnBC,oBAAqB,EACrBC,qBAAsB,EACtBC,eAAgB,EAChBC,QAAS,EACTC,OAAQ,IAGJC,EAAe,IAAIC,IAAIhB,OAAOiB,OAAOb,IAa3C,MAgBMc,EAAkB,IAAIF,IAhBN,CACpB,cACA,UACA,OACA,aACA,OACA,aACA,YACA,WACA,QACA,UACA,iBACA,mBACA,WCnCF,SAASG,EAAeC,GACtB,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IAAK,IAAIlE,EAAIkE,EAAI,EAAGlE,GAAK,EAAGA,IAAK,CAC/B,IAAIoB,EAAM,EACV,IAAK,IAAI9B,EAAIU,EAAI,EAAGV,EAAI4E,EAAG5E,IACzB8B,GAAO2D,EAAQ/E,GAAIV,GAAM/F,EAAE+F,GAE7B/F,EAAEyG,IAAM+E,EAAQ/E,GAAIkE,GAAM9C,GAAO2D,EAAQ/E,GAAIA,EAC9C,CAED,OAAOzG,CACT,CL0nBa+E,CAAMvD,EAAQX,IAEvBkC,MAAOD,EAAa,IAEtB,WAAY,CACVwF,SAAU,EAAEzH,GAAS/F,KAEnB,GADAoG,EAAeL,EAAQ/F,GACnBsL,EAAavF,GACf,MAAO,CAAC,EAAG,GAIb,MAAO,CAFGvF,KAAKuH,KAAKhC,EAAO,IAAM,EAAIA,EAAO,IAAM,GACpCvF,KAAKmQ,MAAM5K,EAAO,GAAIA,EAAO,MAG7CkC,MAAOD,EAAa,IAEtB,aAAc,CACZwF,SAAU,EAAEtD,GAAQlK,KAClBoG,EAAe8D,EAAOlK,GACtB,MAAO4Q,EAAGC,GAAS3G,EACnB,OAAU,IAAN0G,EACK,CAAC,EAAG,GAEN,CAACA,EAAIpQ,KAAKkN,IAAImD,GAAQD,EAAIpQ,KAAKoN,IAAIiD,KAE5C5I,MAAOD,EAAa,KAIxB,IAAK,MAAO3E,EAAKyN,KAASxP,OAAOyP,QAAQ5I,GACnCoF,EAA8BlK,KAChCkK,EAA8BlK,GAAKyN,KAAOA,GAGjC,MAAAE,EAAkC,CAC7CvP,KAAM,iBACNwP,UAAW1D"}
|
|
1
|
+
{"version":3,"file":"linear-algebra.esm.js","sources":["../../src/utils/debug/getCodeMarker.ts","../../src/errors.ts","../../src/constants/constants.ts","../../src/utils/debug/debugTools.ts","../../src/utils/symbols.ts","../../src/typeGuards/number.ts","../../src/utils/debug/getSourceCodeInfo.ts","../../src/typeGuards/annotatedArrays.ts","../../src/builtin/modules/vector/calcMean.ts","../../src/builtin/modules/vector/calcMedian.ts","../../src/builtin/modules/vector/calcStdDev.ts","../../src/builtin/modules/vector/calcVariance.ts","../../src/utils/arity.ts","../../src/builtin/modules/linear-algebra/docs.ts","../../src/utils/index.ts","../../src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.ts","../../src/builtin/modules/linear-algebra/helpers/collinear.ts","../../src/builtin/modules/linear-algebra/helpers/isZeroVector.ts","../../src/builtin/modules/linear-algebra/helpers/pearsonCorr.ts","../../src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.ts","../../src/builtin/modules/linear-algebra/helpers/covariance.ts","../../src/builtin/modules/linear-algebra/helpers/getUnit.ts","../../src/builtin/modules/linear-algebra/helpers/dot.ts","../../src/builtin/modules/linear-algebra/helpers/subtract.ts","../../src/builtin/modules/linear-algebra/helpers/scale.ts","../../src/builtin/modules/linear-algebra/index.ts","../../src/builtin/modules/vector/calcMedad.ts","../../src/builtin/modules/linear-algebra/helpers/length.ts","../../src/builtin/modules/linear-algebra/helpers/kendallTau.ts","../../src/builtin/modules/linear-algebra/helpers/corrleation.ts","../../src/builtin/modules/linear-algebra/helpers/solve.ts"],"sourcesContent":["import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getCodeMarker(sourceCodeInfo: SourceCodeInfo): string {\n if (!sourceCodeInfo.position || !sourceCodeInfo.code)\n return ''\n\n const leftPadding = sourceCodeInfo.position.column - 1\n const rightPadding = sourceCodeInfo.code.length - leftPadding - 1\n return `${' '.repeat(Math.max(leftPadding, 0))}^${' '.repeat(Math.max(rightPadding, 0))}`\n}\n","import { getCodeMarker } from '../src/utils/debug/getCodeMarker'\nimport type { Arr } from './interface'\nimport type { SourceCodeInfo } from './tokenizer/token'\n\nfunction getLitsErrorMessage(message: string, sourceCodeInfo?: SourceCodeInfo) {\n if (!sourceCodeInfo) {\n return message\n }\n const location = `${sourceCodeInfo.position.line}:${sourceCodeInfo.position.column}`\n const filePathLine = sourceCodeInfo.filePath\n ? `\\n${sourceCodeInfo.filePath}:${location}`\n : `\\nLocation ${location}`\n const codeLine = `\\n${sourceCodeInfo.code}`\n const codeMarker = `\\n${getCodeMarker(sourceCodeInfo)}`\n return `${message}${filePathLine}${codeLine}${codeMarker}`\n}\n\nexport class RecurSignal extends Error {\n public params: Arr\n constructor(params: Arr) {\n super(`recur, params: ${params}`)\n Object.setPrototypeOf(this, RecurSignal.prototype)\n this.name = 'RecurSignal'\n this.params = params\n }\n}\n\nexport class LitsError extends Error {\n public readonly sourceCodeInfo?: SourceCodeInfo\n public readonly shortMessage: string\n constructor(err: unknown, sourceCodeInfo: SourceCodeInfo | undefined) {\n const message = err instanceof Error\n ? err.message\n : `${err}`\n\n super(getLitsErrorMessage(message, sourceCodeInfo))\n this.shortMessage = message\n this.sourceCodeInfo = sourceCodeInfo\n Object.setPrototypeOf(this, LitsError.prototype)\n this.name = 'LitsError'\n }\n\n public getCodeMarker(): string | undefined {\n return this.sourceCodeInfo && getCodeMarker(this.sourceCodeInfo)\n }\n}\n\nexport class UserDefinedError extends LitsError {\n public userMessage: string\n constructor(message: string, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n this.userMessage = message\n Object.setPrototypeOf(this, UserDefinedError.prototype)\n this.name = 'UserDefinedError'\n }\n}\n\nexport class AssertionError extends LitsError {\n constructor(message: string | Error, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n Object.setPrototypeOf(this, AssertionError.prototype)\n this.name = 'AssertionError'\n }\n}\n\nexport class UndefinedSymbolError extends LitsError {\n public symbol: string\n constructor(symbolName: string, sourceCodeInfo?: SourceCodeInfo) {\n const message = `Undefined symbol '${symbolName}'.`\n super(message, sourceCodeInfo)\n this.symbol = symbolName\n Object.setPrototypeOf(this, UndefinedSymbolError.prototype)\n this.name = 'UndefinedSymbolError'\n }\n}\n\nexport function isLitsError(error: unknown): error is LitsError {\n return error instanceof LitsError\n}\n","export const NodeTypes = {\n Number: 1,\n String: 2,\n NormalExpression: 3,\n SpecialExpression: 4,\n UserDefinedSymbol: 5,\n NormalBuiltinSymbol: 6,\n SpecialBuiltinSymbol: 7,\n ReservedSymbol: 8,\n Binding: 9,\n Spread: 10,\n} as const\n\nconst NodeTypesSet = new Set(Object.values(NodeTypes))\n\nexport type NodeType = typeof NodeTypes[keyof typeof NodeTypes]\n\nexport function getNodeTypeName(type: NodeType): keyof typeof NodeTypes {\n return Object.keys(NodeTypes).find(key => NodeTypes[key as keyof typeof NodeTypes] === type) as keyof typeof NodeTypes\n}\n\n// TODO, is this needed?\nexport function isNodeType(type: unknown): type is NodeType {\n return typeof type === 'number' && NodeTypesSet.has(type as NodeType)\n}\n\nconst functionTypes = [\n 'UserDefined',\n 'Partial',\n 'Comp',\n 'Constantly',\n 'Juxt',\n 'Complement',\n 'EveryPred',\n 'SomePred',\n 'Fnull',\n 'Builtin',\n 'SpecialBuiltin',\n 'NativeJsFunction',\n 'Module',\n] as const\n\nconst functionTypeSet = new Set(functionTypes)\n\nexport type FunctionType = typeof functionTypes[number]\n\nexport function isFunctionType(type: unknown): type is FunctionType {\n return typeof type === 'string' && functionTypeSet.has(type as FunctionType)\n}\n","import { getNodeTypeName, isFunctionType, isNodeType } from '../../constants/constants'\nimport type { AstNode, LitsFunction } from '../../parser/types'\nimport { FUNCTION_SYMBOL } from '../symbols'\n\nfunction isLitsFunction(func: unknown): func is LitsFunction {\n if (func === null || typeof func !== 'object')\n return false\n\n return FUNCTION_SYMBOL in func && 'functionType' in func && isFunctionType(func.functionType)\n}\n\nfunction isNode(value: unknown): value is AstNode {\n if (!Array.isArray(value) || value.length < 2)\n return false\n return isNodeType(value[0])\n}\n\nexport function valueToString(value: unknown): string {\n if (isLitsFunction(value))\n // eslint-disable-next-line ts/no-unsafe-member-access\n return `<function ${(value as any).name || '\\u03BB'}>`\n\n if (isNode(value))\n return `${getNodeTypeName(value[0])}-node`\n\n if (value === null)\n return 'null'\n\n if (typeof value === 'object' && value instanceof RegExp)\n return `${value}`\n\n if (typeof value === 'object' && value instanceof Error)\n return value.toString()\n\n return JSON.stringify(value)\n}\n","export const FUNCTION_SYMBOL = '^^fn^^'\nexport const REGEXP_SYMBOL = '^^re^^'\n","import { LitsError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\ntype SignOptions =\n | {\n positive?: true\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: true\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: true\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: true\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: true\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: true\n }\n\ntype GtOptions =\n | {\n gt?: number\n gte?: never\n }\n | {\n gt?: never\n gte?: number\n }\n\ntype LtOptions =\n | {\n lt?: number\n lte?: never\n }\n | {\n lt?: never\n lte?: number\n }\n\ntype NumberOptions = {\n integer?: true\n finite?: true\n} & SignOptions &\nGtOptions &\nLtOptions\n\nfunction getRangeString(options: NumberOptions): string {\n const hasUpperAndLowerBound\n = (typeof options.gt === 'number' || typeof options.gte === 'number')\n && (typeof options.lt === 'number' || typeof options.lte === 'number')\n if (hasUpperAndLowerBound) {\n return `${typeof options.gt === 'number' ? `${options.gt} < n ` : `${options.gte} <= n `}${\n typeof options.lt === 'number' ? `< ${options.lt}` : `<= ${options.lte}`\n }`\n }\n else if (typeof options.gt === 'number' || typeof options.gte === 'number') {\n return `${typeof options.gt === 'number' ? `n > ${options.gt}` : `n >= ${options.gte}`}`\n }\n else if (typeof options.lt === 'number' || typeof options.lte === 'number') {\n return `${typeof options.lt === 'number' ? `n < ${options.lt}` : `n <= ${options.lte}`}`\n }\n else { return '' }\n}\n\nfunction getSignString(options: NumberOptions): string {\n return options.positive\n ? 'positive'\n : options.negative\n ? 'negative'\n : options.nonNegative\n ? 'non negative'\n : options.nonPositive\n ? 'non positive'\n : options.nonZero\n ? 'non zero'\n : ''\n}\n\nfunction getNumberTypeName(options: NumberOptions): string {\n if (options.zero)\n return 'zero'\n\n const sign = getSignString(options)\n const numberType = options.integer ? 'integer' : 'number'\n const finite = options.finite ? 'finite' : ''\n const range = getRangeString(options)\n\n return [sign, finite, numberType, range].filter(x => !!x).join(' ')\n}\n\nexport function isNumber(value: unknown, options: NumberOptions = {}): value is number {\n if (typeof value !== 'number')\n return false\n\n if (Number.isNaN(value))\n return false\n\n if (options.integer && !Number.isInteger(value))\n return false\n\n if (options.finite && !Number.isFinite(value))\n return false\n\n if (options.zero && value !== 0)\n return false\n\n if (options.nonZero && value === 0)\n return false\n\n if (options.positive && value <= 0)\n return false\n\n if (options.negative && value >= 0)\n return false\n\n if (options.nonPositive && value > 0)\n return false\n\n if (options.nonNegative && value < 0)\n return false\n\n if (typeof options.gt === 'number' && value <= options.gt)\n return false\n\n if (typeof options.gte === 'number' && value < options.gte)\n return false\n\n if (typeof options.lt === 'number' && value >= options.lt)\n return false\n\n if (typeof options.lte === 'number' && value > options.lte)\n return false\n\n return true\n}\n\nexport function assertNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n options: NumberOptions = {},\n): asserts value is number {\n if (!isNumber(value, options)) {\n throw new LitsError(\n `Expected ${getNumberTypeName(options)}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asNumber(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: NumberOptions = {},\n): number {\n assertNumber(value, sourceCodeInfo, options)\n return value\n}\n","import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getSourceCodeInfo(anyValue: any, sourceCodeInfo: SourceCodeInfo | undefined): SourceCodeInfo | undefined {\n // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access\n return anyValue?.sourceCodeInfo ?? sourceCodeInfo\n}\n","import { LitsError } from '../errors'\nimport type { Any } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isNumber } from './number'\n\nconst annotatedArrays = new WeakSet<unknown[]>()\nconst vectors = new WeakSet<unknown[]>()\nconst notVectors = new WeakSet<unknown[]>()\nconst matrices = new WeakSet<unknown[]>()\nconst notMatrices = new WeakSet<unknown[]>()\nconst grids = new WeakSet<unknown[]>()\nconst notGrids = new WeakSet<unknown[]>()\n\nexport function annotate<T>(value: T): T {\n if (!Array.isArray(value)) {\n return value\n }\n if (annotatedArrays.has(value)) {\n return value\n }\n isVector(value)\n if (!isMatrix(value)) {\n isGrid(value)\n }\n\n return value\n}\nexport function isVector(vector: unknown): vector is number[] {\n if (!Array.isArray(vector)) {\n return false\n }\n\n if (vectors.has(vector)) {\n return true\n }\n if (notVectors.has(vector)) {\n return false\n }\n\n if (vector.every(elem => isNumber(elem))) {\n annotatedArrays.add(vector)\n vectors.add(vector)\n return true\n }\n notVectors.add(vector)\n return false\n}\n\nexport function assertVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n if (!isVector(vector)) {\n throw new LitsError(`Expected a vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is2dVector(vector: unknown): vector is [number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 2\n}\nexport function assert2dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number] {\n if (!is2dVector(vector)) {\n throw new LitsError(`Expected a 2d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is3dVector(vector: unknown): vector is [number, number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 3\n}\nexport function assert3dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number, number] {\n if (!is3dVector(vector)) {\n throw new LitsError(`Expected a 3d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function assertNonEmptyVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n assertVector(vector, sourceCodeInfo)\n if (vector.length === 0) {\n throw new LitsError(`Expected a non empty vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function isGrid(grid: unknown): grid is unknown[][] {\n if (!Array.isArray(grid)) {\n return false\n }\n if (grids.has(grid)) {\n return true\n }\n if (notGrids.has(grid)) {\n return false\n }\n if (grid.length === 0) {\n notGrids.add(grid)\n return false\n }\n if (!Array.isArray(grid[0])) {\n notGrids.add(grid)\n return false\n }\n const nbrOfCols = grid[0].length\n for (const row of grid.slice(1)) {\n if (!Array.isArray(row)) {\n notGrids.add(grid)\n return false\n }\n if (row.length !== nbrOfCols) {\n notGrids.add(grid)\n return false\n }\n }\n annotatedArrays.add(grid)\n grids.add(grid)\n return true\n}\n\nexport function assertGrid(grid: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts grid is Any[][] {\n if (!isGrid(grid)) {\n throw new LitsError(`Expected a grid, but got ${grid}`, sourceCodeInfo)\n }\n}\n\nexport function isMatrix(matrix: unknown): matrix is number[][] {\n if (!Array.isArray(matrix)) {\n return false\n }\n if (matrices.has(matrix)) {\n return true\n }\n if (notMatrices.has(matrix)) {\n return false\n }\n if (matrix.length === 0) {\n notMatrices.add(matrix)\n return false\n }\n if (!Array.isArray(matrix[0]) || matrix[0].length === 0) {\n notMatrices.add(matrix)\n return false\n }\n const nbrOfCols = matrix[0].length\n for (const row of matrix) {\n if (!Array.isArray(row) || row.length !== nbrOfCols || row.some(cell => !isNumber(cell))) {\n notMatrices.add(matrix)\n return false\n }\n }\n annotatedArrays.add(matrix)\n grids.add(matrix)\n matrices.add(matrix)\n return true\n}\n\nexport function assertMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new LitsError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n}\n\nexport function assertSquareMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new LitsError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n if (matrix.length !== matrix[0]!.length) {\n throw new LitsError(`Expected square matrix, but got ${matrix.length} and ${matrix[0]!.length}`, sourceCodeInfo)\n }\n}\n\nexport function isSquareMatrix(matrix: unknown): matrix is number[][] {\n if (!isMatrix(matrix)) {\n return false\n }\n if (matrix.length !== matrix[0]!.length) {\n return false\n }\n return true\n}\n","export function calcMean(vector: number[]): number {\n if (vector.length === 0) {\n return 0\n }\n\n const sum = vector.reduce((acc, val) => acc + val, 0)\n return sum / vector.length\n}\n","export function calcMedian(vector: number[]): number {\n const sorted = [...vector].sort((a, b) => a - b)\n const mid = Math.floor(sorted.length / 2)\n\n return sorted.length % 2 === 0\n ? (sorted[mid - 1]! + sorted[mid]!) / 2\n : sorted[mid]!\n}\n","import { calcVariance } from './calcVariance'\n\nexport function calcStdDev(vector: number[], optionalMean?: number): number {\n const variance = calcVariance(vector, optionalMean)\n return Math.sqrt(variance)\n}\n\nexport function calcSampleStdDev(vector: number[], optionalMean?: number): number {\n const variance = calcVariance(vector, optionalMean)\n return Math.sqrt(variance * (vector.length / (vector.length - 1)))\n}\n","import { calcMean } from './calcMean'\n\nexport function calcVariance(vector: number[], optionalMean?: number): number {\n const mean = optionalMean ?? calcMean(vector)\n return vector.reduce((acc, val) => acc + (val - mean) ** 2, 0) / vector.length\n}\n\nexport function calcSampleVariance(vector: number[], optionalMean?: number): number {\n const mean = optionalMean ?? calcMean(vector)\n return vector.reduce((acc, val) => acc + (val - mean) ** 2, 0) / (vector.length - 1)\n}\n","import type { Arity } from '../builtin/interface'\nimport { LitsError } from '../errors'\nimport type { FunctionLike } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isColl } from '../typeGuards/lits'\nimport { valueToString } from './debug/debugTools'\n\nexport function arityAccepts(arity: Arity, nbrOfParams: number): boolean {\n const { min, max } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n if (typeof max === 'number' && nbrOfParams > max) {\n return false\n }\n return true\n}\n\nexport function arityAcceptsMin(arity: Arity, nbrOfParams: number): boolean {\n const { min } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n return true\n}\n\nexport function getCommonArityFromFunctions(params: FunctionLike[]): Arity | null {\n return params.reduce((acc: Arity | null, param): Arity | null => {\n if (acc === null) {\n return null\n }\n const arity: Arity = (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n const { min: aMin, max: aMax } = arity\n const { min: bMin, max: bMax } = acc\n const min = typeof aMin === 'number' && typeof bMin === 'number'\n ? Math.max(aMin, bMin)\n : typeof aMin === 'number' ? aMin : typeof bMin === 'number' ? bMin : undefined\n const max = typeof aMax === 'number' && typeof bMax === 'number'\n ? Math.min(aMax, bMax)\n : typeof aMax === 'number' ? aMax : typeof bMax === 'number' ? bMax : undefined\n\n if (typeof min === 'number' && typeof max === 'number' && min > max) {\n return null\n }\n\n return { min, max }\n }, {})\n}\n\nexport function getArityFromFunction(param: FunctionLike): Arity {\n return (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n}\n\nexport function assertNumberOfParams(arity: Arity, length: number, sourceCodeInfo: SourceCodeInfo | undefined): void {\n const { min, max } = arity\n if (typeof min === 'number' && length < min) {\n throw new LitsError(\n `Wrong number of arguments, expected at least ${min}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n\n if (typeof max === 'number' && length > max) {\n throw new LitsError(\n `Wrong number of arguments, expected at most ${max}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n}\n\nexport function canBeOperator(count: Arity): boolean {\n if (typeof count.max === 'number' && count.max < 2) {\n return false\n }\n\n if (typeof count.min === 'number' && count.min > 2) {\n return false\n }\n\n return true\n}\n\nexport function toFixedArity(arity: number): Arity {\n return { min: arity, max: arity }\n}\n","import type { FunctionDocs } from '../../interface'\n\nexport const moduleDocs: Record<string, FunctionDocs> = {\n 'reflect': {\n category: 'linear-algebra',\n description: 'Reflects a vector across a given axis.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to reflect.',\n },\n b: {\n type: 'vector',\n description: 'Axis of reflection.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { reflect } = import(\"linear-algebra\");\\nreflect([1, 2], [0, 1])',\n 'let { reflect } = import(\"linear-algebra\");\\nreflect([1, 2, 3], [0, 0, 1])',\n ],\n seeAlso: ['linear-algebra.refract', 'linear-algebra.projection'],\n },\n 'refract': {\n category: 'linear-algebra',\n description: 'Refracts a vector across a given axis.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Vector to refract.',\n },\n axis: {\n type: 'vector',\n description: 'Axis of refraction.',\n },\n eta: {\n type: 'number',\n description: 'Refraction index.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'axis',\n 'eta',\n ],\n },\n ],\n examples: [\n 'let { refract } = import(\"linear-algebra\");\\nrefract([1, 2], [0, 1], 1.5)',\n 'let { refract } = import(\"linear-algebra\");\\nrefract([1, 2, 3], [0, 0, 1], 1.5)',\n ],\n seeAlso: ['linear-algebra.reflect'],\n },\n 'lerp': {\n category: 'linear-algebra',\n description: 'Performs linear interpolation between two vectors.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Start vector.',\n },\n b: {\n type: 'vector',\n description: 'End vector.',\n },\n t: {\n type: 'number',\n description: 'Interpolation factor (0 to 1).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n 't',\n ],\n },\n ],\n examples: [\n 'let { lerp } = import(\"linear-algebra\");\\nlerp([1, 2], [3, 4], 0.5)',\n 'let { lerp } = import(\"linear-algebra\");\\nlerp([1, 2], [3, 4], 2)',\n 'let { lerp } = import(\"linear-algebra\");\\nlerp([1, 2], [3, 4], -1)',\n 'let { lerp } = import(\"linear-algebra\");\\nlerp([1, 2, 3], [4, 5, 6], 0.25)',\n ],\n seeAlso: ['linear-algebra.projection'],\n },\n 'rotate2d': {\n category: 'linear-algebra',\n description: 'Rotates a 2D vector by a given angle in radians.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to rotate.',\n },\n b: {\n type: 'number',\n description: 'Angle in b.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { rotate2d } = import(\"linear-algebra\");\\nrotate2d([1, 0], PI / 2)',\n 'let { rotate2d } = import(\"linear-algebra\");\\nrotate2d([0, 1], PI)',\n ],\n seeAlso: ['linear-algebra.rotate3d', 'linear-algebra.angle'],\n },\n 'rotate3d': {\n category: 'linear-algebra',\n description: 'Rotates a 3D vector around a given axis by a given angle in radians.',\n returns: {\n type: 'vector',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to rotate.',\n },\n axis: {\n type: 'vector',\n description: 'Axis of rotation.',\n },\n radians: {\n type: 'number',\n description: 'Angle in radians.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n 'axis',\n 'radians',\n ],\n },\n ],\n examples: [\n 'let { rotate3d } = import(\"linear-algebra\");\\nrotate3d([1, 0, 0], [0, 1, 0], PI / 2)',\n 'let { rotate3d } = import(\"linear-algebra\");\\nrotate3d([0, 1, 0], [1, 0, 0], PI)',\n ],\n seeAlso: ['linear-algebra.rotate2d', 'linear-algebra.angle'],\n },\n 'dot': {\n category: 'linear-algebra',\n description: 'Calculates the dot product of two vectors. The result is a scalar.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'First vector.',\n },\n b: {\n type: 'vector',\n description: 'Second vector.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { dot } = import(\"linear-algebra\");\\ndot([1, 2], [3, 4])',\n 'let { dot } = import(\"linear-algebra\");\\ndot([1, 2, 3], [4, 5, 6])',\n ],\n seeAlso: ['linear-algebra.cross', 'linear-algebra.cosine-similarity', 'linear-algebra.angle', 'linear-algebra.projection', 'linear-algebra.orthogonal?'],\n },\n 'cross': {\n category: 'linear-algebra',\n description: 'Calculates the cross product of two 3D vectors. The result is a vector perpendicular to both input vectors.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'First vector (3D).',\n },\n b: {\n type: 'vector',\n description: 'Second vector (3D).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cross } = import(\"linear-algebra\");\\ncross([1, 2, 3], [4, 5, 6])',\n 'let { cross } = import(\"linear-algebra\");\\ncross([1, 0, 0], [0, 1, 0])',\n 'let { cross } = import(\"linear-algebra\");\\ncross([0, 0, 1], [1, 0, 0])',\n 'let { cross } = import(\"linear-algebra\");\\ncross([1, 2, 3], [0, 0, 0])',\n 'let { cross } = import(\"linear-algebra\");\\ncross([0, 0, 0], [1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.dot'],\n },\n 'normalize-minmax': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using min-max normalization. The result is a vector with values between 0 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, 3])',\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, -3])',\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, 3, 4])',\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, -3, 4])',\n 'let { normalize-minmax } = import(\"linear-algebra\");\\nnormalize-minmax([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-zscore', 'linear-algebra.normalize-robust', 'linear-algebra.normalize-l1', 'linear-algebra.normalize-l2', 'linear-algebra.normalize-log'],\n },\n 'normalize-zscore': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using z-score normalization. The result is a vector with mean 0 and standard deviation 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, 3])',\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, -3])',\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, 3, 4])',\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, -3, 4])',\n 'let { normalize-zscore } = import(\"linear-algebra\");\\nnormalize-zscore([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-minmax', 'linear-algebra.normalize-robust', 'linear-algebra.normalize-l1', 'linear-algebra.normalize-l2', 'linear-algebra.normalize-log'],\n },\n 'normalize-robust': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using robust normalization. The result is a vector with median 0 and median absolute deviation 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, 3])',\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, -3])',\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, 3, 4])',\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, -3, 4])',\n 'let { normalize-robust } = import(\"linear-algebra\");\\nnormalize-robust([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-minmax', 'linear-algebra.normalize-zscore'],\n },\n 'normalize-l1': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using L1 normalization. The result is a vector with L1 norm equal to 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, 3])',\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, -3])',\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, 3, 4])',\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, -3, 4])',\n 'let { normalize-l1 } = import(\"linear-algebra\");\\nnormalize-l1([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-l2', 'linear-algebra.normalize-minmax', 'linear-algebra.manhattan-norm', 'linear-algebra.normalize-zscore'],\n },\n 'normalize-l2': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using L2 normalization. The result is a vector with L2 norm equal to 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, 3])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, 3])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, -3])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, 3, 4])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, -3, 4])',\n 'let { normalize-l2 } = import(\"linear-algebra\");\\nnormalize-l2([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-l1', 'linear-algebra.normalize-minmax', 'linear-algebra.euclidean-norm', 'linear-algebra.normalize-zscore'],\n },\n 'normalize-log': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using natural log normalization. The result is a vector with log-transformed values.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-log } = import(\"linear-algebra\");\\nnormalize-log([1, 2, 3])',\n 'let { normalize-log } = import(\"linear-algebra\");\\nnormalize-log([1, 2, 3, 4])',\n 'let { normalize-log } = import(\"linear-algebra\");\\nnormalize-log([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-minmax', 'linear-algebra.normalize-zscore'],\n },\n 'angle': {\n category: 'linear-algebra',\n description: 'Calculates the **angle** between two vectors in radians.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { angle } = import(\"linear-algebra\");\\nangle([1, 0], [0, 1])',\n 'let { angle } = import(\"linear-algebra\");\\nangle([1, 0, 1], [0, 1, 0])',\n ],\n seeAlso: ['linear-algebra.dot', 'linear-algebra.collinear?', 'linear-algebra.orthogonal?', 'linear-algebra.rotate2d', 'linear-algebra.rotate3d', 'linear-algebra.parallel?', 'linear-algebra.cosine-similarity', 'linear-algebra.to-polar'],\n },\n 'projection': {\n category: 'linear-algebra',\n description: 'Calculates the **projection** of vector `a` onto vector `b`.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { projection } = import(\"linear-algebra\");\\nprojection([1, 2], [3, 4])',\n 'let { projection } = import(\"linear-algebra\");\\nprojection([1, 2, 3], [4, 5, 6])',\n ],\n seeAlso: ['linear-algebra.dot', 'linear-algebra.reflect', 'linear-algebra.lerp'],\n },\n 'collinear?': {\n category: 'linear-algebra',\n description: 'Checks if two vectors are **collinear**.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { collinear? } = import(\"linear-algebra\");\\ncollinear?([1, 2], [2, 4])',\n 'let { collinear? } = import(\"linear-algebra\");\\ncollinear?([1, 2], [-2, -4])',\n 'let { collinear? } = import(\"linear-algebra\");\\ncollinear?([1, 2, 3], [2, 4, 6])',\n ],\n seeAlso: ['linear-algebra.parallel?', 'linear-algebra.orthogonal?', 'linear-algebra.angle'],\n },\n 'parallel?': {\n category: 'linear-algebra',\n description: 'Checks if two vectors are **parallel**.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { parallel? } = import(\"linear-algebra\");\\nparallel?([1, 2], [2, 4])',\n 'let { parallel? } = import(\"linear-algebra\");\\nparallel?([1, 2], [-2, -4])',\n 'let { parallel? } = import(\"linear-algebra\");\\nparallel?([1, 2, 3], [2, 4, 6])',\n 'let { parallel? } = import(\"linear-algebra\");\\nparallel?([1, 2], [3, 4])',\n ],\n seeAlso: ['linear-algebra.collinear?', 'linear-algebra.orthogonal?', 'linear-algebra.angle'],\n },\n 'orthogonal?': {\n category: 'linear-algebra',\n description: 'Checks if two vectors are **orthogonal**.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { orthogonal? } = import(\"linear-algebra\");\\northogonal?([1, 0], [0, 1])',\n 'let { orthogonal? } = import(\"linear-algebra\");\\northogonal?([1, 0, 1], [0, 1, 0])',\n 'let { orthogonal? } = import(\"linear-algebra\");\\northogonal?([1, 2], [2, -1])',\n ],\n seeAlso: ['linear-algebra.collinear?', 'linear-algebra.parallel?', 'linear-algebra.dot', 'matrix.orthogonal?', 'linear-algebra.angle'],\n },\n 'cosine-similarity': {\n category: 'linear-algebra',\n description: 'Calculates the **cosine similarity** between two vectors. The result is a value between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cosine-similarity } = import(\"linear-algebra\");\\ncosine-similarity([1, 2], [3, 4])',\n 'let { cosine-similarity } = import(\"linear-algebra\");\\ncosine-similarity([1, 2, 3], [4, 5, 6])',\n 'let { cosine-similarity } = import(\"linear-algebra\");\\ncosine-similarity([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.dot', 'linear-algebra.angle', 'linear-algebra.euclidean-distance'],\n },\n 'euclidean-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Euclidean distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { euclidean-distance } = import(\"linear-algebra\");\\neuclidean-distance([1, 2], [3, 4])',\n 'let { euclidean-distance } = import(\"linear-algebra\");\\neuclidean-distance([1, 2, 3], [4, 5, 6])',\n 'let { euclidean-distance } = import(\"linear-algebra\");\\neuclidean-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.manhattan-distance', 'linear-algebra.chebyshev-distance', 'linear-algebra.minkowski-distance', 'linear-algebra.euclidean-norm', 'linear-algebra.cosine-similarity', 'linear-algebra.hamming-distance'],\n },\n 'euclidean-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Euclidean norm** (L2 norm) of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { euclidean-norm } = import(\"linear-algebra\");\\neuclidean-norm([1, 2])',\n 'let { euclidean-norm } = import(\"linear-algebra\");\\neuclidean-norm([3, 4])',\n 'let { euclidean-norm } = import(\"linear-algebra\");\\neuclidean-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.manhattan-norm', 'linear-algebra.chebyshev-norm', 'linear-algebra.minkowski-norm', 'linear-algebra.euclidean-distance', 'linear-algebra.normalize-l2', 'linear-algebra.hamming-norm'],\n },\n 'manhattan-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Manhattan distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { manhattan-distance } = import(\"linear-algebra\");\\nmanhattan-distance([1, 2], [3, 4])',\n 'let { manhattan-distance } = import(\"linear-algebra\");\\nmanhattan-distance([1, 2, 3], [4, 5, 6])',\n 'let { manhattan-distance } = import(\"linear-algebra\");\\nmanhattan-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.chebyshev-distance', 'linear-algebra.minkowski-distance', 'linear-algebra.manhattan-norm', 'linear-algebra.hamming-distance'],\n },\n 'manhattan-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Manhattan norm** (L1 norm) of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { manhattan-norm } = import(\"linear-algebra\");\\nmanhattan-norm([1, 2])',\n 'let { manhattan-norm } = import(\"linear-algebra\");\\nmanhattan-norm([3, 4])',\n 'let { manhattan-norm } = import(\"linear-algebra\");\\nmanhattan-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.chebyshev-norm', 'linear-algebra.minkowski-norm', 'linear-algebra.manhattan-distance', 'linear-algebra.normalize-l1', 'linear-algebra.hamming-norm'],\n },\n 'hamming-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Hamming distance** between two vectors. The result is a non-negative integer.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { hamming-distance } = import(\"linear-algebra\");\\nhamming-distance([1, 2], [3, 4])',\n 'let { hamming-distance } = import(\"linear-algebra\");\\nhamming-distance([1, 2, 3], [4, 5, 6])',\n 'let { hamming-distance } = import(\"linear-algebra\");\\nhamming-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.manhattan-distance', 'linear-algebra.hamming-norm'],\n },\n 'hamming-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Hamming norm** of a vector. The result is a non-negative integer.',\n returns: {\n type: 'integer',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { hamming-norm } = import(\"linear-algebra\");\\nhamming-norm([1, 2])',\n 'let { hamming-norm } = import(\"linear-algebra\");\\nhamming-norm([3, 4])',\n 'let { hamming-norm } = import(\"linear-algebra\");\\nhamming-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.manhattan-norm', 'linear-algebra.hamming-distance'],\n },\n 'chebyshev-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Chebyshev distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { chebyshev-distance } = import(\"linear-algebra\");\\nchebyshev-distance([1, 2], [3, 4])',\n 'let { chebyshev-distance } = import(\"linear-algebra\");\\nchebyshev-distance([1, 2, 3], [4, 5, 6])',\n 'let { chebyshev-distance } = import(\"linear-algebra\");\\nchebyshev-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.manhattan-distance', 'linear-algebra.minkowski-distance', 'linear-algebra.chebyshev-norm'],\n },\n 'chebyshev-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Chebyshev norm** of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { chebyshev-norm } = import(\"linear-algebra\");\\nchebyshev-norm([1, 2])',\n 'let { chebyshev-norm } = import(\"linear-algebra\");\\nchebyshev-norm([3, 4])',\n 'let { chebyshev-norm } = import(\"linear-algebra\");\\nchebyshev-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.manhattan-norm', 'linear-algebra.minkowski-norm', 'linear-algebra.chebyshev-distance'],\n },\n 'minkowski-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Minkowski distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n p: {\n type: 'number',\n description: 'Order of the norm (p).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n 'p',\n ],\n },\n ],\n examples: [\n 'let { minkowski-distance } = import(\"linear-algebra\");\\nminkowski-distance([1, 2], [3, 4], 2)',\n 'let { minkowski-distance } = import(\"linear-algebra\");\\nminkowski-distance([1, 2, 3], [4, 5, 6], 3)',\n 'let { minkowski-distance } = import(\"linear-algebra\");\\nminkowski-distance([1, 0], [0, 1], 1)',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.manhattan-distance', 'linear-algebra.chebyshev-distance', 'linear-algebra.minkowski-norm'],\n },\n 'minkowski-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Minkowski norm** of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n b: {\n type: 'number',\n description: 'Order of the norm (p).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { minkowski-norm } = import(\"linear-algebra\");\\nminkowski-norm([1, 2], 2)',\n 'let { minkowski-norm } = import(\"linear-algebra\");\\nminkowski-norm([3, 4], 3)',\n 'let { minkowski-norm } = import(\"linear-algebra\");\\nminkowski-norm([1, 2, 3], 4)',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.manhattan-norm', 'linear-algebra.chebyshev-norm', 'linear-algebra.minkowski-distance'],\n },\n 'cov': {\n category: 'linear-algebra',\n description: 'Calculates the **covariance** between two vectors. The result is a number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cov } = import(\"linear-algebra\");\\ncov([1, 2], [3, 4])',\n 'let { cov } = import(\"linear-algebra\");\\ncov([1, 2, 3], [4, 5, 6])',\n 'let { cov } = import(\"linear-algebra\");\\ncov([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.corr', 'linear-algebra.pearson-corr', 'vector.variance'],\n },\n 'corr': {\n category: 'linear-algebra',\n description: 'Calculates the **correlation** between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { corr } = import(\"linear-algebra\");\\ncorr([1, 2], [3, 4])',\n 'let { corr } = import(\"linear-algebra\");\\ncorr([1, 2, 3], [4, 5, 6])',\n 'let { corr } = import(\"linear-algebra\");\\ncorr([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.cov', 'linear-algebra.pearson-corr', 'linear-algebra.spearman-corr', 'linear-algebra.kendall-tau', 'linear-algebra.autocorrelation', 'linear-algebra.cross-correlation'],\n },\n 'spearman-corr': {\n category: 'linear-algebra',\n description: 'Calculates the **Spearman rank correlation** between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { spearman-corr } = import(\"linear-algebra\");\\nspearman-corr([1, 2], [3, 4])',\n 'let { spearman-corr } = import(\"linear-algebra\");\\nspearman-corr([1, 2, 3], [4, 5, 6])',\n 'let { spearman-corr } = import(\"linear-algebra\");\\nspearman-corr([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.pearson-corr', 'linear-algebra.kendall-tau', 'linear-algebra.corr'],\n },\n 'pearson-corr': {\n category: 'linear-algebra',\n description: 'Calculates the **Pearson correlation** between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { pearson-corr } = import(\"linear-algebra\");\\npearson-corr([1, 2], [3, 4])',\n 'let { pearson-corr } = import(\"linear-algebra\");\\npearson-corr([1, 2, 3], [4, 5, 6])',\n 'let { pearson-corr } = import(\"linear-algebra\");\\npearson-corr([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.spearman-corr', 'linear-algebra.kendall-tau', 'linear-algebra.corr', 'linear-algebra.cov'],\n },\n 'kendall-tau': {\n category: 'linear-algebra',\n description: 'Calculates the **Kendall Tau** rank correlation coefficient between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { kendall-tau } = import(\"linear-algebra\");\\nkendall-tau([1, 2], [3, 4])',\n 'let { kendall-tau } = import(\"linear-algebra\");\\nkendall-tau([1, 2, 3], [4, 5, 6])',\n 'let { kendall-tau } = import(\"linear-algebra\");\\nkendall-tau([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.spearman-corr', 'linear-algebra.pearson-corr', 'linear-algebra.corr'],\n },\n 'autocorrelation': {\n category: 'linear-algebra',\n description: 'Calculates the **autocorrelation** of a vector. The result is a vector of autocorrelation coefficients.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to calculate the autocorrelation for.',\n },\n b: {\n type: 'integer',\n description: 'Lag value for the autocorrelation.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], -2)',\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], -1)',\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], 0)',\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], 1)',\n 'let { autocorrelation } = import(\"linear-algebra\");\\nautocorrelation([1, 2, 3], 2)',\n ],\n seeAlso: ['linear-algebra.cross-correlation', 'linear-algebra.corr'],\n },\n 'cross-correlation': {\n category: 'linear-algebra',\n description: 'Calculates the **cross-correlation** between two vectors. The result is a vector of cross-correlation coefficients.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n lag: {\n type: 'integer',\n description: 'Lag value for the cross-correlation.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n 'lag',\n ],\n },\n ],\n examples: [\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], -2)',\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], -1)',\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], 0)',\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], 1)',\n 'let { cross-correlation } = import(\"linear-algebra\");\\ncross-correlation([1, 2, 3], [4, 5, 6], 2)',\n ],\n seeAlso: ['linear-algebra.autocorrelation', 'linear-algebra.corr'],\n },\n 'rref': {\n category: 'linear-algebra',\n description: 'Calculates the **Reduced Row Echelon Form** (RREF) of a matrix.',\n returns: {\n type: 'matrix',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'Matrix to calculate the RREF for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { rref } = import(\"linear-algebra\");\\nrref([[1, 2], [3, 4]])',\n 'let { rref } = import(\"linear-algebra\");\\nrref([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n 'let { rref } = import(\"linear-algebra\");\\nrref([[1, 2, 3], [7, 8, 9], [4, 5, 7]])',\n ],\n seeAlso: ['linear-algebra.solve', 'matrix.rank'],\n },\n 'solve': {\n category: 'linear-algebra',\n description: 'Solves a system of linear equations represented by a matrix and a vector.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'matrix',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { solve } = import(\"linear-algebra\");\\nsolve([\\n [2, 1, -1, 1], \\n [4, 5, -3, 2], \\n [6, -2, 5, -3], \\n [8, 3, 2, 4]\\n], [5, 10, 2, 17])',\n 'let { solve } = import(\"linear-algebra\"); solve([[2, 0, 0], [3, 1, 0], [4, 5, 6]], [4, 5, 38])',\n 'let { solve } = import(\"linear-algebra\"); solve([[2, 3], [1, -1]], [8, 2])',\n ],\n seeAlso: ['linear-algebra.rref', 'matrix.inv'],\n },\n 'to-polar': {\n category: 'linear-algebra',\n description: 'Converts a 2D vector to polar coordinates.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: '2D Vector to convert.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { to-polar } = import(\"linear-algebra\");\\nto-polar([1, 2])',\n 'let { to-polar } = import(\"linear-algebra\");\\nto-polar([3, 4])',\n ],\n seeAlso: ['linear-algebra.from-polar', 'linear-algebra.angle'],\n },\n 'from-polar': {\n category: 'linear-algebra',\n description: 'Converts polar coordinates to a 2D vector.',\n returns: {\n type: 'vector',\n },\n args: {\n polar: {\n type: 'vector',\n description: 'Polar coordinates to convert.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'polar',\n ],\n },\n ],\n examples: [\n 'let { from-polar } = import(\"linear-algebra\");\\nfrom-polar([1, PI / 4])',\n 'let { from-polar } = import(\"linear-algebra\");\\nfrom-polar([1, 0])',\n 'let { from-polar } = import(\"linear-algebra\");\\nfrom-polar([1, -PI / 2])',\n ],\n seeAlso: ['linear-algebra.to-polar'],\n },\n}\n","import type { Any, Coll, Obj } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asAny, isColl, isObj, isRegularExpression } from '../typeGuards/lits'\nimport { isNumber } from '../typeGuards/number'\nimport { asString, assertStringOrNumber } from '../typeGuards/string'\nimport { isUnknownRecord } from '../typeGuards'\nimport { LitsError } from '../errors'\n\nexport function collHasKey(coll: unknown, key: string | number): boolean {\n if (!isColl(coll))\n return false\n\n if (typeof coll === 'string' || Array.isArray(coll)) {\n if (!isNumber(key, { integer: true }))\n return false\n\n return key >= 0 && key < coll.length\n }\n return !!Object.getOwnPropertyDescriptor(coll, key)\n}\n\nexport function compare<T extends string | number>(a: T, b: T, sourceCodeInfo: SourceCodeInfo | undefined): number {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a < b ? -1 : a > b ? 1 : 0\n }\n if (typeof a === 'number' && typeof b === 'number') {\n return Math.sign((a) - (b))\n }\n throw new LitsError(`Cannot compare values of different types: ${typeof a} and ${typeof b}`, sourceCodeInfo)\n}\n\nexport function deepEqual(a: unknown, b: unknown, sourceCodeInfo?: SourceCodeInfo): boolean {\n if (a === b)\n return true\n\n if (typeof a === 'number' && typeof b === 'number')\n return approxEqual(a, b)\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length)\n return false\n\n for (let i = 0; i < a.length; i += 1) {\n if (!deepEqual(asAny(a[i], sourceCodeInfo), asAny(b[i], sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n }\n if (isRegularExpression(a) && isRegularExpression(b))\n return a.s === b.s && a.f === b.f\n\n if (isUnknownRecord(a) && isUnknownRecord(b)) {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length)\n return false\n\n for (let i = 0; i < aKeys.length; i += 1) {\n const key = asString(aKeys[i], sourceCodeInfo)\n if (!deepEqual(a[key], b[key], sourceCodeInfo))\n return false\n }\n return true\n }\n return false\n}\n\nexport function toNonNegativeInteger(num: number): number {\n return Math.max(0, Math.ceil(num))\n}\n\nexport function toAny(value: unknown): Any {\n return (value ?? null) as Any\n}\n\nfunction clone<T>(value: T): T {\n if (isObj(value)) {\n return Object.entries(value).reduce((result: Obj, entry) => {\n const [key, val] = entry\n result[key] = clone(val)\n return result\n }, {}) as T\n }\n if (Array.isArray(value))\n // eslint-disable-next-line ts/no-unsafe-return\n return value.map(item => clone(item)) as unknown as T\n\n return value\n}\n\nexport function cloneColl<T extends Coll>(value: T): T {\n return clone(value)\n}\n\nexport function joinSets<T>(...results: Set<T>[]): Set<T> {\n const result = new Set<T>()\n for (const symbols of results)\n symbols.forEach(symbol => result.add(symbol))\n\n return result\n}\n\nexport function addToSet<T>(target: Set<T>, source: Set<T>): void {\n source.forEach(symbol => target.add(symbol))\n}\n\nexport const EPSILON = 1e-10\n\nexport function approxEqual(a: number, b: number, epsilon: number = EPSILON): boolean {\n if (a === b) {\n return true\n }\n\n const diff = Math.abs(a - b)\n\n if (a === 0 || b === 0 || diff < epsilon) {\n // Use absolute error for values near zero\n return diff < epsilon\n }\n const absA = Math.abs(a)\n const absB = Math.abs(b)\n\n // Use relative error for larger values\n return diff / (absA + absB) < epsilon\n}\n\nexport function approxZero(value: number): boolean {\n return Math.abs(value) < EPSILON\n}\n\nexport function smartTrim(str: string, minIndent = 0): string {\n const lines = str.split('\\n')\n while (lines[0]?.match(/^\\s*$/)) {\n lines.shift() // Remove leading empty lines\n }\n while (lines[lines.length - 1]?.match(/^\\s*$/)) {\n lines.pop() // Remove trailing empty lines\n }\n const indent = lines.reduce((acc, line) => {\n if (line.match(/^\\s*$/))\n return acc // Skip empty lines\n const lineIndent = line.match(/^\\s*/)![0].length\n return Math.min(acc, lineIndent)\n }, Infinity)\n return lines.map(line => ' '.repeat(minIndent) + line.slice(indent)).join('\\n').trimEnd()\n}\n","import { approxZero } from '../../../../utils'\n\n/**\n * Performs Gauss-Jordan elimination on a matrix, transforming it to reduced row echelon form\n *\n * @param matrix - The input matrix\n * @returns A tuple containing the reduced row echelon form matrix and the rank\n */\nexport function gaussJordanElimination(matrix: number[][]): [number[][], number] {\n // Create a copy of the matrix to avoid modifying the original\n const m = matrix.map(row => [...row])\n const rows = m.length\n const cols = m[0]!.length\n\n let rank = 0\n let rowsProcessed = 0\n\n // Row reduction to reduced row echelon form\n for (let col = 0; col < cols; col++) {\n // Find the pivot\n let pivotRow = -1\n\n for (let row = rowsProcessed; row < rows; row++) {\n if (!approxZero(m[row]![col]!)) {\n pivotRow = row\n break\n }\n }\n\n if (pivotRow === -1)\n continue // No pivot in this column\n\n // Increase rank\n rank += 1\n\n // Swap rows\n if (pivotRow !== rowsProcessed) {\n [m[pivotRow], m[rowsProcessed]] = [m[rowsProcessed]!, m[pivotRow]!]\n }\n\n // Get the pivot value\n const pivotValue = m[rowsProcessed]![col]!\n\n // Normalize the pivot row (always, for RREF)\n for (let j = col; j < cols; j++) {\n m[rowsProcessed]![j]! /= pivotValue\n }\n\n // Eliminate above and below (full Gauss-Jordan)\n for (let row = 0; row < rows; row++) {\n if (row !== rowsProcessed && !approxZero(m[row]![col]!)) {\n const factor = m[row]![col]!\n for (let j = col; j < cols; j++) {\n m[row]![j]! -= factor * m[rowsProcessed]![j]!\n }\n }\n }\n\n rowsProcessed++\n if (rowsProcessed === rows)\n break\n }\n\n return [m, rank]\n}\n","import { approxEqual, approxZero } from '../../../../utils'\n\nexport function areVectorsCollinear(vectorA: number[], vectorB: number[]): boolean {\n // Check if either vector is zero\n const isZeroVector = (vec: number[]): boolean =>\n vec.every(component => approxZero(component))\n\n if (isZeroVector(vectorA) || isZeroVector(vectorB)) {\n return true // Zero vector is technically collinear to all vectors\n }\n\n // Find the first non-zero component in vectorA\n let index = 0\n while (index < vectorA.length && approxZero(vectorA[index]!)) {\n index++\n }\n\n // Calculate the scale factor\n const ratio = vectorB[index]! / vectorA[index]!\n\n // Check if all other components maintain the same ratio\n for (let i = 0; i < vectorA.length; i++) {\n // Skip components where both vectors have (near) zero values\n if (approxZero(vectorA[i]!) && approxZero(vectorB[i]!))\n continue\n\n // If vectorA component is near zero but vectorB is not, vectors are not collinear\n if (approxZero(vectorA[i]!))\n return false\n\n // Check if the ratio is consistent\n if (!approxEqual(vectorB[i]! / vectorA[i]!, ratio)) {\n return false\n }\n }\n\n return true\n}\n\nexport function areVectorsParallel(vectorA: number[], vectorB: number[]): boolean {\n if (!areVectorsCollinear(vectorA, vectorB)) {\n return false\n }\n\n // Then verify they point in the same direction\n // Find first non-zero component in both vectors\n for (let i = 0; i < vectorA.length; i++) {\n if (!approxZero(vectorA[i]!) && !approxZero(vectorB[i]!)) {\n return Math.sign(vectorA[i]!) === Math.sign(vectorB[i]!)\n }\n }\n\n // If we get here, one of the vectors must be zero\n return true\n}\n","import { approxZero } from '../../../../utils'\n\nexport function isZeroVector(vector: number[]): boolean {\n return vector.every(component => approxZero(component))\n}\n","import { calcMean } from '../../vector/calcMean'\n\nexport function pearsonCorr(vectorA: number[], vectorB: number[]): number {\n const meanA = calcMean(vectorA)\n const meanB = calcMean(vectorB)\n\n let sumNumerator = 0\n let sumSquareA = 0\n let sumSquareB = 0\n\n for (let i = 0; i < vectorA.length; i++) {\n const diffA = vectorA[i]! - meanA\n const diffB = vectorB[i]! - meanB\n\n sumNumerator += diffA * diffB\n sumSquareA += diffA * diffA\n sumSquareB += diffB * diffB\n }\n\n // Check if either vector has zero variance\n if (sumSquareA === 0 || sumSquareB === 0) {\n throw new Error('Cannot calculate Pearson correlation coefficient: one of the vectors has zero variance.')\n }\n\n return sumNumerator / (Math.sqrt(sumSquareA) * Math.sqrt(sumSquareB))\n}\n","export function calcFractionalRanks(vector: number[]): number[] {\n // Create array of indices and sort by values\n const indices = [...vector.keys()].sort((a, b) => vector[a]! - vector[b]!)\n\n // Create ranks array (same size as input vector)\n const ranks: number[] = Array.from<number>({ length: vector.length }).fill(0)\n\n // Assign ranks, handling ties properly\n let currentRank = 1\n let i = 0\n while (i < indices.length) {\n const value = vector[indices[i]!]\n let j = i\n\n // Find all indices with the same value\n while (j < indices.length && vector[indices[j]!] === value) {\n j++\n }\n\n // Calculate average rank for ties\n const averageRank = currentRank + (j - i - 1) / 2\n\n // Assign average rank to all tied elements\n for (let k = i; k < j; k++) {\n ranks[indices[k]!] = averageRank\n }\n\n // Update current rank and index\n currentRank += j - i\n i = j\n }\n\n return ranks\n}\n","import { calcMean } from '../../vector/calcMean'\n\n/**\n * Calculate covariance between two segments\n */\nexport function calcCovariance(segmentA: number[], segmentB: number[]): number {\n const meanA = calcMean(segmentA)\n const meanB = calcMean(segmentB)\n\n let sum = 0\n for (let i = 0; i < segmentA.length; i++) {\n sum += (segmentA[i]! - meanA) * (segmentB[i]! - meanB)\n }\n\n return sum / segmentA.length\n}\n","import { LitsError } from '../../../../errors'\nimport type { SourceCodeInfo } from '../../../../tokenizer/token'\nimport { approxZero } from '../../../../utils'\n\nexport function getUnit<T extends number[]>(\n value: T,\n sourceCodeInfo: SourceCodeInfo | undefined,\n): T {\n if (value.length === 0) {\n return value\n }\n const length = Math.sqrt(value.reduce((acc, item) => acc + item ** 2, 0))\n if (approxZero(length)) {\n throw new LitsError('The vector must not be zero', sourceCodeInfo)\n }\n return value.map(item => item / length) as T\n}\n","export function dot(\n vector1: number[],\n vector2: number[],\n): number {\n return vector1.reduce((acc, item, index) => acc + item * vector2[index]!, 0)\n}\n","export function subtract<T extends number[]>(\n vector1: T,\n vector2: T,\n): T {\n return vector1.map((item, index) => item - vector2[index]!) as T\n}\n","export function scale<T extends number[]>(\n vector: T,\n scalar: number,\n): T {\n return vector.map(item => item * scalar) as T\n}\n","import { LitsError } from '../../../errors'\nimport { assert2dVector, assert3dVector, assertMatrix, assertNonEmptyVector, assertSquareMatrix, assertVector } from '../../../typeGuards/annotatedArrays'\nimport { assertNumber } from '../../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport type { LitsModule } from '../interface'\nimport { calcMean } from '../vector/calcMean'\nimport { calcMedad } from '../vector/calcMedad'\nimport { calcMedian } from '../vector/calcMedian'\nimport { calcStdDev } from '../vector/calcStdDev'\nimport { toFixedArity } from '../../../utils/arity'\nimport { moduleDocs } from './docs'\nimport { gaussJordanElimination } from './helpers/gaussJordanElimination'\nimport { solve } from './helpers/solve'\nimport { areVectorsCollinear, areVectorsParallel } from './helpers/collinear'\nimport { isZeroVector } from './helpers/isZeroVector'\nimport { pearsonCorr } from './helpers/pearsonCorr'\nimport { calcFractionalRanks } from './helpers/calcFractionalRanks'\nimport { kendallTau } from './helpers/kendallTau'\nimport { calcCovariance } from './helpers/covariance'\nimport { calcCorrelation, extractOverlappingSegments } from './helpers/corrleation'\nimport { getUnit } from './helpers/getUnit'\nimport { dot } from './helpers/dot'\nimport { subtract } from './helpers/subtract'\nimport { scale } from './helpers/scale'\nimport { length } from './helpers/length'\n\nexport const linearAlgebraNormalExpression: BuiltinNormalExpressions = {\n 'rotate2d': {\n evaluate: ([vector, radians], sourceCodeInfo): number[] => {\n assert2dVector(vector, sourceCodeInfo)\n if (isZeroVector(vector)) {\n return vector\n }\n assertNumber(radians, sourceCodeInfo, { finite: true })\n const cosTheta = Math.cos(radians)\n const sinTheta = Math.sin(radians)\n return [\n vector[0] * cosTheta - vector[1] * sinTheta,\n vector[0] * sinTheta + vector[1] * cosTheta,\n ]\n },\n arity: toFixedArity(2),\n },\n 'rotate3d': {\n evaluate: ([vector, axis, radians], sourceCodeInfo): number[] => {\n assert3dVector(vector, sourceCodeInfo)\n if (isZeroVector(vector)) {\n return vector\n }\n assertNumber(radians, sourceCodeInfo, { finite: true })\n assert3dVector(axis, sourceCodeInfo)\n if (isZeroVector(axis)) {\n throw new LitsError('Rotation axis must not be zero', sourceCodeInfo)\n }\n const cosTheta = Math.cos(radians)\n const sinTheta = Math.sin(radians)\n const [u, v, w] = getUnit(axis, sourceCodeInfo)\n const dotProduct = vector[0] * u + vector[1] * v + vector[2] * w\n return [\n dotProduct * u * (1 - cosTheta) + vector[0] * cosTheta + (-w * vector[1] + v * vector[2]) * sinTheta,\n dotProduct * v * (1 - cosTheta) + vector[1] * cosTheta + (w * vector[0] - u * vector[2]) * sinTheta,\n dotProduct * w * (1 - cosTheta) + vector[2] * cosTheta + (-v * vector[0] + u * vector[1]) * sinTheta,\n ]\n },\n arity: toFixedArity(3),\n },\n 'reflect': {\n evaluate: ([vector, normal], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n assertVector(normal, sourceCodeInfo)\n if (vector.length !== normal.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n if (isZeroVector(normal)) {\n throw new LitsError('Reflection normal must not be zero', sourceCodeInfo)\n }\n if (isZeroVector(vector)) {\n return vector\n }\n const unitNormal = getUnit(normal, sourceCodeInfo)\n const doubleDot = 2 * dot(vector, unitNormal)\n return subtract(vector, scale(unitNormal, doubleDot))\n },\n arity: toFixedArity(2),\n },\n 'refract': {\n evaluate: ([vector, normal, eta], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n assertVector(normal, sourceCodeInfo)\n assertNumber(eta, sourceCodeInfo, { finite: true, positive: true })\n if (vector.length !== normal.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n if (isZeroVector(normal)) {\n throw new LitsError('Refraction normal must not be zero', sourceCodeInfo)\n }\n if (isZeroVector(vector)) {\n return vector\n }\n // Make sure vectors are normalized\n const normalizedV = getUnit(vector, sourceCodeInfo)\n const normalizedNormal = getUnit(normal, sourceCodeInfo)\n\n // Calculate dot product between incident vector and normal\n const dotProduct = dot(normalizedV, normalizedNormal)\n\n // Calculate discriminant\n const discriminant = 1 - eta * eta * (1 - dotProduct * dotProduct)\n\n // Check for total internal reflection\n if (discriminant < 0) {\n return vector // Total internal reflection occurs\n }\n\n // Calculate the refracted vector\n const scaledIncident = scale(normalizedV, eta)\n const scaledNormal = scale(\n normalizedNormal,\n eta * dotProduct + Math.sqrt(discriminant),\n )\n\n return subtract(scaledIncident, scaledNormal)\n },\n arity: toFixedArity(3),\n },\n 'lerp': {\n evaluate: ([vectorA, vectorB, t], sourceCodeInfo): number[] => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n assertNumber(t, sourceCodeInfo, { finite: true })\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n return vectorA.map((val, i) => val + (vectorB[i]! - val) * t)\n },\n arity: toFixedArity(3),\n },\n 'dot': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return dot(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'cross': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number[] => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== 3 || vectorB.length !== 3) {\n throw new LitsError('Cross product is only defined for 3D vectors', sourceCodeInfo)\n }\n\n return [\n vectorA[1]! * vectorB[2]! - vectorA[2]! * vectorB[1]!,\n vectorA[2]! * vectorB[0]! - vectorA[0]! * vectorB[2]!,\n vectorA[0]! * vectorB[1]! - vectorA[1]! * vectorB[0]!,\n ] as number[]\n },\n arity: toFixedArity(2),\n },\n 'normalize-minmax': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n if (vector.length === 0) {\n return []\n }\n\n const min = vector.reduce((acc, val) => (val < acc ? val : acc), vector[0]!)\n const max = vector.reduce((acc, val) => (val > acc ? val : acc), vector[0]!)\n\n if (min === max) {\n return vector.map(() => 0)\n }\n\n return vector.map(val => (val - min) / (max - min))\n },\n arity: toFixedArity(1),\n },\n 'normalize-robust': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n if (vector.length === 0) {\n return []\n }\n\n const median = calcMedian(vector)\n const medad = calcMedad(vector)\n\n if (medad === 0) {\n return vector.map(val => val - median)\n }\n return vector.map(val => (val - median) / medad)\n },\n arity: toFixedArity(1),\n },\n 'normalize-zscore': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n const mean = calcMean(vector)\n const stdDev = calcStdDev(vector)\n\n if (stdDev === 0) {\n return vector.map(() => 0)\n }\n\n return vector.map(val => (val - mean) / stdDev)\n },\n arity: toFixedArity(1),\n },\n 'normalize-l1': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length === 0) {\n return []\n }\n const norm = vector.reduce((acc, val) => acc + Math.abs(val), 0)\n\n if (norm === 0) {\n return vector.map(() => 0)\n }\n\n return vector.map(val => val / norm)\n },\n arity: toFixedArity(1),\n },\n 'normalize-l2': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n return getUnit(vector, sourceCodeInfo)\n },\n arity: toFixedArity(1),\n },\n 'normalize-log': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n if (vector.length === 0) {\n return []\n }\n\n const min = Math.min(...vector)\n\n if (min <= 0) {\n throw new LitsError('Log normalization requires all values to be positive', sourceCodeInfo)\n }\n\n return vector.map(val => Math.log(val / min))\n },\n arity: toFixedArity(1),\n },\n 'angle': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (isZeroVector(vectorA) || isZeroVector(vectorB)) {\n throw new LitsError('Cannot calculate angle with zero-length vector', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n const magnitudeA = Math.sqrt(vectorA.reduce((acc, val) => acc + val * val, 0))\n const magnitudeB = Math.sqrt(vectorB.reduce((acc, val) => acc + val * val, 0))\n\n return Math.acos(dotProduct / (magnitudeA * magnitudeB))\n },\n arity: toFixedArity(2),\n },\n 'projection': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number[] => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (isZeroVector(vectorB)) {\n throw new LitsError('Cannot project onto zero-length vector', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n const magnitudeB = Math.sqrt(vectorB.reduce((acc, val) => acc + val * val, 0))\n\n return vectorB.map(val => (dotProduct / (magnitudeB ** 2)) * val)\n },\n arity: toFixedArity(2),\n },\n 'orthogonal?': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): boolean => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n return dotProduct === 0\n },\n arity: toFixedArity(2),\n },\n 'parallel?': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): boolean => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return areVectorsParallel(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'collinear?': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): boolean => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return areVectorsCollinear(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'cosine-similarity': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (isZeroVector(vectorA) || isZeroVector(vectorB)) {\n throw new LitsError('Cannot calculate cosine similarity with zero-length vector', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n const magnitudeA = Math.sqrt(vectorA.reduce((acc, val) => acc + val * val, 0))\n const magnitudeB = Math.sqrt(vectorB.reduce((acc, val) => acc + val * val, 0))\n\n return dotProduct / (magnitudeA * magnitudeB)\n },\n arity: toFixedArity(2),\n },\n 'euclidean-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return Math.sqrt(vectorA.reduce((acc, val, i) => acc + (val - vectorB[i]!) ** 2, 0))\n },\n arity: toFixedArity(2),\n },\n 'euclidean-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n\n return length(vector)\n },\n arity: toFixedArity(1),\n },\n 'manhattan-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return vectorA.reduce((acc, val, i) => acc + Math.abs(val - vectorB[i]!), 0)\n },\n arity: toFixedArity(2),\n },\n 'manhattan-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n\n return vector.reduce((acc, val) => acc + Math.abs(val), 0)\n },\n arity: toFixedArity(1),\n },\n 'hamming-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return vectorA.reduce((acc, val, i) => acc + (val !== vectorB[i]! ? 1 : 0), 0)\n },\n arity: toFixedArity(2),\n },\n 'hamming-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + (val !== 0 ? 1 : 0), 0)\n },\n arity: toFixedArity(1),\n },\n 'chebyshev-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return Math.max(...vectorA.map((val, i) => Math.abs(val - vectorB[i]!)))\n },\n arity: toFixedArity(2),\n },\n 'chebyshev-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return Math.max(...vector.map(val => Math.abs(val)))\n },\n arity: toFixedArity(1),\n },\n 'minkowski-distance': {\n evaluate: ([vectorA, vectorB, p], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n assertNumber(p, sourceCodeInfo, { finite: true, positive: true })\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return vectorA.reduce((acc, val, i) => acc + Math.abs(val - vectorB[i]!) ** p, 0) ** (1 / p)\n },\n arity: toFixedArity(3),\n },\n 'minkowski-norm': {\n evaluate: ([vector, p], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n assertNumber(p, sourceCodeInfo, { finite: true, positive: true })\n return vector.reduce((acc, val) => acc + Math.abs(val) ** p, 0) ** (1 / p)\n },\n arity: toFixedArity(2),\n },\n 'cov': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n if (vectorA.length === 1) {\n return 0\n }\n\n return calcCovariance(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'corr': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length <= 1) {\n throw new LitsError('Vectors must have at least 2 elements for corr', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const meanA = calcMean(vectorA)\n const meanB = calcMean(vectorB)\n\n const numerator = vectorA.reduce((acc, val, i) => acc + (val - meanA) * (vectorB[i]! - meanB), 0)\n const denominator = Math.sqrt(\n vectorA.reduce((acc, val) => acc + (val - meanA) ** 2, 0) * vectorB.reduce((acc, val) => acc + (val - meanB) ** 2, 0),\n )\n\n return numerator / denominator\n },\n arity: toFixedArity(2),\n },\n 'spearman-corr': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length <= 1) {\n throw new LitsError('Vectors must have at least 2 elements for corr', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const ranksA = calcFractionalRanks(vectorA)\n const ranksB = calcFractionalRanks(vectorB)\n\n try {\n return pearsonCorr(ranksA, ranksB)\n }\n catch (error) {\n throw new LitsError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'pearson-corr': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length <= 1) {\n throw new LitsError('Vectors must have at least 2 elements for pearson-corr', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n try {\n return pearsonCorr(vectorA, vectorB)\n }\n catch (error) {\n throw new LitsError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'kendall-tau': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length < 2) {\n throw new LitsError('Vectors must have at least 2 elements for kendall-tau', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n try {\n return kendallTau(vectorA, vectorB)\n }\n catch (error) {\n throw new LitsError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'autocorrelation': {\n evaluate: ([vector, lag], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length < 2) {\n throw new LitsError('Vector must have at least 2 elements for autocorrelation', sourceCodeInfo)\n }\n\n assertNumber(lag, sourceCodeInfo, {\n integer: true,\n lt: vector.length,\n gt: -vector.length,\n })\n\n // For lag 0, return 1 (a series is perfectly correlated with itself)\n if (lag === 0) {\n return 1\n }\n const absLag = Math.abs(lag)\n const mean = calcMean(vector)\n\n // Calculate the numerator (sum of products of deviations)\n let numerator = 0\n const n = vector.length\n\n // If lag is positive, correlate current with past values\n // If lag is negative, correlate current with future values (same calculation, different interpretation)\n for (let i = 0; i < n - absLag; i++) {\n const currentIndex = lag < 0 ? i + absLag : i\n const laggedIndex = lag < 0 ? i : i + absLag\n\n numerator += (vector[currentIndex]! - mean) * (vector[laggedIndex]! - mean)\n }\n\n // Calculate the denominator (sum of squared deviations)\n let denominator = 0\n for (let i = 0; i < n; i++) {\n denominator += (vector[i]! - mean) ** 2\n }\n\n // Handle edge case of zero variance\n if (denominator === 0) {\n return 0 // Conventional definition\n }\n\n // Return the autocorrelation coefficient\n return numerator / denominator\n },\n arity: toFixedArity(2),\n },\n\n 'cross-correlation': {\n evaluate: ([vectorA, vectorB, lag], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length < 2) {\n throw new LitsError('Vectors must have at least 2 elements', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new LitsError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n assertNumber(lag, sourceCodeInfo, {\n integer: true,\n lt: vectorA.length,\n gt: -vectorA.length,\n })\n\n // For lag 0 between identical vectors, return 1\n if (lag === 0\n && vectorA.length === vectorB.length\n && vectorA.every((v, i) => v === vectorB[i])) {\n return 1\n }\n\n const [segmentA, segmentB] = extractOverlappingSegments(vectorA, vectorB, lag)\n return calcCorrelation(segmentA, segmentB)\n },\n arity: toFixedArity(3),\n },\n 'rref': {\n evaluate: ([matrix], sourceCodeInfo): number[][] => {\n assertMatrix(matrix, sourceCodeInfo)\n\n // Reduced Row Echelon Form (RREF)\n const [rref] = gaussJordanElimination(matrix)\n return rref\n },\n arity: toFixedArity(1),\n },\n 'solve': {\n evaluate: ([matrix, vector], sourceCodeInfo): number[] | null => {\n assertSquareMatrix(matrix, sourceCodeInfo)\n assertVector(vector, sourceCodeInfo)\n if (matrix.length !== vector.length) {\n throw new LitsError(`The number of rows in the matrix must be equal to the length of the vector, but got ${matrix.length} and ${vector.length}`, sourceCodeInfo)\n }\n return solve(matrix, vector)\n },\n arity: toFixedArity(2),\n },\n 'to-polar': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assert2dVector(vector, sourceCodeInfo)\n if (isZeroVector(vector)) {\n return [0, 0]\n }\n const r = Math.sqrt(vector[0] ** 2 + vector[1] ** 2)\n const theta = Math.atan2(vector[1], vector[0])\n return [r, theta]\n },\n arity: toFixedArity(1),\n },\n 'from-polar': {\n evaluate: ([polar], sourceCodeInfo): number[] => {\n assert2dVector(polar, sourceCodeInfo)\n const [r, theta] = polar\n if (r === 0) {\n return [0, 0]\n }\n return [r * Math.cos(theta), r * Math.sin(theta)]\n },\n arity: toFixedArity(1),\n },\n}\n\nfor (const [key, docs] of Object.entries(moduleDocs)) {\n if (linearAlgebraNormalExpression[key])\n linearAlgebraNormalExpression[key].docs = docs\n}\n\nexport const linearAlgebraModule: LitsModule = {\n name: 'linear-algebra',\n functions: linearAlgebraNormalExpression,\n}\n","import { calcMedian } from './calcMedian'\n\nexport function calcMedad(vector: number[]): number {\n const median = calcMedian(vector)\n // Calculate absolute deviations from the median\n const absoluteDeviations = vector.map(val => Math.abs(val - median))\n\n // Calculate the median of the absolute deviations\n const medianOfDeviations = calcMedian(absoluteDeviations)\n const scaleFactor = 1.4826 // Scale factor for robust scaling\n\n return medianOfDeviations * scaleFactor\n}\n","export function length(vector: number[]): number {\n return Math.sqrt(vector.reduce((acc, item) => acc + item ** 2, 0))\n}\n","/**\n * Calculates Kendall's Tau-b rank correlation coefficient between two vectors\n * This implementation handles ties and uses an epsilon value for floating-point comparisons\n *\n * @param vectorA - First vector of numbers\n * @param vectorB - Second vector of numbers\n * @param epsilon - Threshold for considering two values as equal (default: 1e-10)\n * @returns The Kendall's Tau-b correlation coefficient\n */\nexport function kendallTau(vectorA: number[], vectorB: number[], epsilon: number = 1e-10): number {\n let concordant = 0\n let discordant = 0\n let tiesInA = 0\n let tiesInB = 0\n\n // Compare all pairs\n for (let i = 0; i < vectorA.length; i++) {\n for (let j = i + 1; j < vectorA.length; j++) {\n // Calculate differences\n const diffA = vectorA[i]! - vectorA[j]!\n const diffB = vectorB[i]! - vectorB[j]!\n\n // Check for ties using epsilon\n const isTieA = Math.abs(diffA) < epsilon\n const isTieB = Math.abs(diffB) < epsilon\n\n if (isTieA && isTieB) {\n // Tied in both vectors\n continue\n }\n else if (isTieA) {\n // Tied in vector A only\n tiesInA += 1\n }\n else if (isTieB) {\n // Tied in vector B only\n tiesInB += 1\n }\n else if (diffA * diffB > 0) {\n // Concordant pair\n concordant += 1\n }\n else {\n // Discordant pair\n discordant += 1\n }\n }\n }\n\n const n1 = concordant + discordant + tiesInA\n const n2 = concordant + discordant + tiesInB\n\n // Handle edge cases to avoid division by zero\n if (n1 === 0 || n2 === 0) {\n throw new Error('Not enough data to calculate Kendall\\'s Tau')\n }\n\n // Kendall's Tau-b formula\n return (concordant - discordant) / Math.sqrt(n1 * n2)\n}\n","import { calcMean } from '../../vector/calcMean'\nimport { calcStdDev } from '../../vector/calcStdDev'\nimport { calcCovariance } from './covariance'\n\n/**\n * Calculate Pearson correlation between two segments\n */\nexport function calcCorrelation(segmentA: number[], segmentB: number[]): number {\n const meanA = calcMean(segmentA)\n const meanB = calcMean(segmentB)\n\n const stdA = calcStdDev(segmentA, meanA)\n const stdB = calcStdDev(segmentB, meanB)\n\n // Handle zero variance\n if (stdA === 0 || stdB === 0) {\n // If both have zero variance and are the same constant, they're perfectly correlated\n if (stdA === 0 && stdB === 0 && meanA === meanB) {\n return 1\n }\n // Otherwise, no meaningful correlation can be established\n return 0\n }\n\n const covariance = calcCovariance(segmentA, segmentB)\n return covariance / (stdA * stdB)\n}\n\n/**\n * Extract overlapping segments from two vectors based on lag\n */\nexport function extractOverlappingSegments(\n vectorA: number[],\n vectorB: number[],\n lag: number,\n): [number[], number[]] {\n const absLag = Math.abs(lag)\n const overlapLength = vectorA.length - absLag\n\n let segmentA = []\n let segmentB = []\n\n if (lag >= 0) {\n segmentA = vectorA.slice(0, overlapLength)\n segmentB = vectorB.slice(lag, lag + overlapLength)\n }\n else {\n segmentA = vectorA.slice(absLag)\n segmentB = vectorB.slice(0, overlapLength)\n }\n\n return [segmentA, segmentB]\n}\n","import { approxZero } from '../../../../utils'\nimport { gaussJordanElimination } from './gaussJordanElimination'\n\n/**\n * Solves a system of linear equations Ax = b\n *\n * @param A - The coefficient matrix\n * @param b - The constant vector\n * @returns The solution vector x, or null if no unique solution exists\n */\nexport function solve(A: number[][], b: number[]): number[] | null {\n const n = A.length\n\n // Create augmented matrix [A|b]\n const augmented = A.map((row, i) => [...row, b[i]!])\n\n // Convert to row echelon form using your existing function\n const [echelon] = gaussJordanElimination(augmented)\n\n // Check if the system has a unique solution\n for (let i = 0; i < n; i += 1) {\n if (approxZero(echelon[i]![i]!)) {\n return null // No unique solution\n }\n }\n\n // Back substitution\n const x = Array.from({ length: n }, () => 0)\n for (let i = n - 1; i >= 0; i--) {\n let sum = 0\n for (let j = i + 1; j < n; j++) {\n sum += echelon[i]![j]! * x[j]!\n }\n x[i] = (echelon[i]![n]! - sum) / echelon[i]![i]!\n }\n\n return x\n}\n"],"names":["getCodeMarker","sourceCodeInfo","position","code","leftPadding","column","rightPadding","length","repeat","Math","max","LitsError","Error","shortMessage","constructor","err","message","super","location","line","filePath","getLitsErrorMessage","this","Object","setPrototypeOf","prototype","name","NodeTypes","Number","String","NormalExpression","SpecialExpression","UserDefinedSymbol","NormalBuiltinSymbol","SpecialBuiltinSymbol","ReservedSymbol","Binding","Spread","NodeTypesSet","Set","values","functionTypeSet","isLitsFunction","func","type","functionType","has","isNode","value","Array","isArray","valueToString","keys","find","key","RegExp","toString","JSON","stringify","isNumber","options","isNaN","integer","isInteger","finite","isFinite","zero","nonZero","positive","negative","nonPositive","nonNegative","gt","gte","lt","lte","assertNumber","sign","getSignString","numberType","range","getRangeString","filter","x","join","getNumberTypeName","anyValue","getSourceCodeInfo","annotatedArrays","WeakSet","vectors","notVectors","matrices","notMatrices","grids","isVector","vector","every","elem","add","assertVector","assert2dVector","is2dVector","assert3dVector","is3dVector","assertNonEmptyVector","isMatrix","matrix","nbrOfCols","row","some","cell","calcMean","reduce","acc","val","calcMedian","sorted","sort","a","b","mid","floor","calcStdDev","optionalMean","variance","mean","calcVariance","sqrt","toFixedArity","arity","min","moduleDocs","reflect","category","description","returns","args","variants","argumentNames","examples","seeAlso","refract","axis","eta","lerp","t","rotate2d","rotate3d","v","radians","dot","cross","angle","projection","p","cov","corr","autocorrelation","lag","rref","m","solve","polar","approxEqual","epsilon","diff","abs","approxZero","gaussJordanElimination","map","rows","cols","rank","rowsProcessed","col","pivotRow","pivotValue","j","factor","areVectorsCollinear","vectorA","vectorB","isZeroVector","vec","component","index","ratio","i","pearsonCorr","meanA","meanB","sumNumerator","sumSquareA","sumSquareB","diffA","diffB","calcFractionalRanks","indices","ranks","from","fill","currentRank","averageRank","k","calcCovariance","segmentA","segmentB","sum","getUnit","item","vector1","vector2","subtract","scale","scalar","linearAlgebraNormalExpression","evaluate","cosTheta","cos","sinTheta","sin","u","w","dotProduct","normal","unitNormal","normalizedV","normalizedNormal","discriminant","median","medad","calcMedad","stdDev","norm","log","magnitudeA","magnitudeB","acos","areVectorsParallel","ranksA","ranksB","error","concordant","discordant","tiesInA","tiesInB","isTieA","isTieB","n1","n2","kendallTau","absLag","numerator","n","laggedIndex","denominator","overlapLength","slice","extractOverlappingSegments","stdA","stdB","calcCorrelation","assertMatrix","assertSquareMatrix","A","augmented","echelon","atan2","r","theta","docs","entries","linearAlgebraModule","functions"],"mappings":"AAEM,SAAUA,EAAcC,GAC5B,IAAKA,EAAeC,WAAaD,EAAeE,KAC9C,MAAO,GAET,MAAMC,EAAcH,EAAeC,SAASG,OAAS,EAC/CC,EAAeL,EAAeE,KAAKI,OAASH,EAAc,EAChE,MAAO,GAAG,IAAII,OAAOC,KAAKC,IAAIN,EAAa,OAAO,IAAII,OAAOC,KAAKC,IAAIJ,EAAc,KACtF,CCkBM,MAAOK,UAAkBC,MACbX,eACAY,aAChB,WAAAC,CAAYC,EAAcd,GACxB,MAAMe,EAAUD,aAAeH,MAC3BG,EAAIC,QACJ,GAAGD,IAEPE,MA/BJ,SAA6BD,EAAiBf,GAC5C,IAAKA,EACH,OAAOe,EAET,MAAME,EAAW,GAAGjB,EAAeC,SA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