New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@visactor/vutils

Package Overview
Dependencies
Maintainers
15
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visactor/vutils - npm Package Compare versions

Comparing version 0.18.2-alpha.0 to 0.18.2

15

cjs/fmin/bisect.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.findZeroOfFunction = void 0;
const logger_1 = require("../logger");
function findZeroOfFunction(f, a, b, parameters) {
const maxIterations = (parameters = parameters || {}).maxIterations || 100, tolerance = parameters.tolerance || 1e-10, fA = f(a), fB = f(b);
let delta = b - a;
if (fA * fB > 0) throw "Initial bisect points must have opposite signs";
if (fA * fB > 0) {
return logger_1.Logger.getInstance().error("Initial bisect points must have opposite signs"),
NaN;
}
if (0 === fA) return a;

@@ -17,5 +26,3 @@ if (0 === fB) return b;

Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.findZeroOfFunction = void 0, exports.findZeroOfFunction = findZeroOfFunction;
exports.findZeroOfFunction = findZeroOfFunction;
//# sourceMappingURL=bisect.js.map
export declare function zeros(x: number): number[];
export declare function zerosM(x: number, y: number): number[][];
export declare function dot(a: number[], b: number[]): number;
export declare function norm2(a: number[]): number;

@@ -5,0 +4,0 @@ export declare function scale(ret: number[], value: number[], c: number): void;

"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.gemv = exports.weightedSum = exports.scale = exports.norm2 = exports.zerosM = exports.zeros = void 0;
const math_1 = require("../math");
function zeros(x) {

@@ -15,10 +21,4 @@ const r = new Array(x);

function dot(a, b) {
let ret = 0;
for (let i = 0; i < a.length; ++i) ret += a[i] * b[i];
return ret;
}
function norm2(a) {
return Math.sqrt(dot(a, a));
return Math.sqrt((0, math_1.dotProduct)(a, a));
}

@@ -35,10 +35,7 @@

function gemv(output, A, x) {
for (let i = 0; i < output.length; ++i) output[i] = dot(A[i], x);
for (let i = 0; i < output.length; ++i) output[i] = (0, math_1.dotProduct)(A[i], x);
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.gemv = exports.weightedSum = exports.scale = exports.norm2 = exports.dot = exports.zerosM = exports.zeros = void 0,
exports.zeros = zeros, exports.zerosM = zerosM, exports.dot = dot, exports.norm2 = norm2,
exports.scale = scale, exports.weightedSum = weightedSum, exports.gemv = gemv;
exports.zeros = zeros, exports.zerosM = zerosM, exports.norm2 = norm2, exports.scale = scale,
exports.weightedSum = weightedSum, exports.gemv = gemv;
//# sourceMappingURL=blas1.js.map

@@ -7,3 +7,3 @@ "use strict";

const blas1_1 = require("./blas1"), linesearch_1 = require("./linesearch");
const math_1 = require("../math"), blas1_1 = require("./blas1"), linesearch_1 = require("./linesearch");

@@ -34,4 +34,4 @@ function conjugateGradient(f, initial, params) {

(0, blas1_1.weightedSum)(yk, 1, next.fxprime, -1, current.fxprime);
const delta_k = (0, blas1_1.dot)(current.fxprime, current.fxprime), beta_k = Math.max(0, (0,
blas1_1.dot)(yk, next.fxprime) / delta_k);
const delta_k = (0, math_1.dotProduct)(current.fxprime, current.fxprime), beta_k = Math.max(0, (0,
math_1.dotProduct)(yk, next.fxprime) / delta_k);
(0, blas1_1.weightedSum)(pk, beta_k, pk, -1, next.fxprime), temp = current, current = next,

@@ -38,0 +38,0 @@ next = temp;

@@ -7,6 +7,6 @@ "use strict";

const blas1_1 = require("./blas1");
const math_1 = require("../math"), blas1_1 = require("./blas1");
function wolfeLineSearch(f, pk, current, next, a, c1, c2) {
const phi0 = current.fx, phiPrime0 = (0, blas1_1.dot)(current.fxprime, pk);
const phi0 = current.fx, phiPrime0 = (0, math_1.dotProduct)(current.fxprime, pk);
let phi = phi0, phi_old = phi0, phiPrime = phiPrime0, a0 = 0;

@@ -16,3 +16,3 @@ function zoom(a_lo, a_high, phi_lo) {

(0, blas1_1.weightedSum)(next.x, 1, current.x, a, pk), phi = next.fx = f(next.x, next.fxprime),
phiPrime = (0, blas1_1.dot)(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || phi >= phi_lo) a_high = a; else {
phiPrime = (0, math_1.dotProduct)(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || phi >= phi_lo) a_high = a; else {
if (Math.abs(phiPrime) <= -c2 * phiPrime0) return a;

@@ -26,3 +26,3 @@ phiPrime * (a_high - a_lo) >= 0 && (a_high = a_lo), a_lo = a, phi_lo = phi;

if ((0, blas1_1.weightedSum)(next.x, 1, current.x, a, pk), phi = next.fx = f(next.x, next.fxprime),
phiPrime = (0, blas1_1.dot)(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || iteration && phi >= phi_old) return zoom(a0, a, phi_old);
phiPrime = (0, math_1.dotProduct)(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || iteration && phi >= phi_old) return zoom(a0, a, phi_old);
if (Math.abs(phiPrime) <= -c2 * phiPrime0) return a;

@@ -29,0 +29,0 @@ if (phiPrime >= 0) return zoom(a, a0, phi);

@@ -64,2 +64,3 @@ export declare const epsilon = 1e-12;

}): number;
export declare function dotProduct(a: number[] | Float32Array, b: number[] | Float32Array): number;
export declare function fuzzyEqualNumber(a: number, b: number): boolean;

@@ -66,0 +67,0 @@ export declare function fuzzyEqualVec(a: vec2, b: vec2): boolean;

@@ -33,2 +33,8 @@ "use strict";

function dotProduct(a, b) {
let ret = 0;
for (let i = 0; i < a.length; ++i) ret += a[i] * b[i];
return ret;
}
function fuzzyEqualNumber(a, b) {

@@ -61,3 +67,3 @@ return (0, exports.abs)(a - b) < exports.epsilon;

value: !0
}), exports.precisionSub = exports.precisionAdd = exports.getDecimalPlaces = exports.fixPrecision = exports.fuzzyEqualVec = exports.fuzzyEqualNumber = exports.crossProductPoint = exports.crossProduct = exports.lengthFromPointToLine = exports.pointAt = exports.asin = exports.acos = exports.pow = exports.sqrt = exports.sin = exports.min = exports.max = exports.cos = exports.atan2 = exports.abs = exports.pi2 = exports.SUBDIVISION_MAX_ITERATIONS = exports.SUBDIVISION_PRECISION = exports.NEWTON_MIN_SLOPE = exports.NEWTON_ITERATIONS = exports.tau = exports.halfPi = exports.pi = exports.epsilon = void 0,
}), exports.precisionSub = exports.precisionAdd = exports.getDecimalPlaces = exports.fixPrecision = exports.fuzzyEqualVec = exports.fuzzyEqualNumber = exports.dotProduct = exports.crossProductPoint = exports.crossProduct = exports.lengthFromPointToLine = exports.pointAt = exports.asin = exports.acos = exports.pow = exports.sqrt = exports.sin = exports.min = exports.max = exports.cos = exports.atan2 = exports.abs = exports.pi2 = exports.SUBDIVISION_MAX_ITERATIONS = exports.SUBDIVISION_PRECISION = exports.NEWTON_MIN_SLOPE = exports.NEWTON_ITERATIONS = exports.tau = exports.halfPi = exports.pi = exports.epsilon = void 0,
exports.epsilon = 1e-12, exports.pi = Math.PI, exports.halfPi = exports.pi / 2,

@@ -70,5 +76,5 @@ exports.tau = 2 * exports.pi, exports.NEWTON_ITERATIONS = 4, exports.NEWTON_MIN_SLOPE = .001,

exports.crossProduct = crossProduct, exports.crossProductPoint = crossProductPoint,
exports.fuzzyEqualNumber = fuzzyEqualNumber, exports.fuzzyEqualVec = fuzzyEqualVec,
exports.dotProduct = dotProduct, exports.fuzzyEqualNumber = fuzzyEqualNumber, exports.fuzzyEqualVec = fuzzyEqualVec,
exports.fixPrecision = fixPrecision, exports.getDecimalPlaces = getDecimalPlaces,
exports.precisionAdd = precisionAdd, exports.precisionSub = precisionSub;
//# sourceMappingURL=math.js.map

@@ -0,5 +1,10 @@

import { Logger } from "../logger";
export function findZeroOfFunction(f, a, b, parameters) {
const maxIterations = (parameters = parameters || {}).maxIterations || 100, tolerance = parameters.tolerance || 1e-10, fA = f(a), fB = f(b);
let delta = b - a;
if (fA * fB > 0) throw "Initial bisect points must have opposite signs";
if (fA * fB > 0) {
return Logger.getInstance().error("Initial bisect points must have opposite signs"),
NaN;
}
if (0 === fA) return a;

@@ -6,0 +11,0 @@ if (0 === fB) return b;

export declare function zeros(x: number): number[];
export declare function zerosM(x: number, y: number): number[][];
export declare function dot(a: number[], b: number[]): number;
export declare function norm2(a: number[]): number;

@@ -5,0 +4,0 @@ export declare function scale(ret: number[], value: number[], c: number): void;

@@ -0,1 +1,3 @@

import { dotProduct } from "../math";
export function zeros(x) {

@@ -13,10 +15,4 @@ const r = new Array(x);

export function dot(a, b) {
let ret = 0;
for (let i = 0; i < a.length; ++i) ret += a[i] * b[i];
return ret;
}
export function norm2(a) {
return Math.sqrt(dot(a, a));
return Math.sqrt(dotProduct(a, a));
}

@@ -33,4 +29,4 @@

export function gemv(output, A, x) {
for (let i = 0; i < output.length; ++i) output[i] = dot(A[i], x);
for (let i = 0; i < output.length; ++i) output[i] = dotProduct(A[i], x);
}
//# sourceMappingURL=blas1.js.map

@@ -1,3 +0,5 @@

import { dot, norm2, scale, weightedSum } from "./blas1";
import { dotProduct } from "../math";
import { norm2, scale, weightedSum } from "./blas1";
import { wolfeLineSearch } from "./linesearch";

@@ -29,3 +31,3 @@

weightedSum(yk, 1, next.fxprime, -1, current.fxprime);
const delta_k = dot(current.fxprime, current.fxprime), beta_k = Math.max(0, dot(yk, next.fxprime) / delta_k);
const delta_k = dotProduct(current.fxprime, current.fxprime), beta_k = Math.max(0, dotProduct(yk, next.fxprime) / delta_k);
weightedSum(pk, beta_k, pk, -1, next.fxprime), temp = current, current = next, next = temp;

@@ -32,0 +34,0 @@ } else scale(pk, current.fxprime, -1);

@@ -1,5 +0,7 @@

import { dot, weightedSum } from "./blas1";
import { dotProduct } from "../math";
import { weightedSum } from "./blas1";
export function wolfeLineSearch(f, pk, current, next, a, c1, c2) {
const phi0 = current.fx, phiPrime0 = dot(current.fxprime, pk);
const phi0 = current.fx, phiPrime0 = dotProduct(current.fxprime, pk);
let phi = phi0, phi_old = phi0, phiPrime = phiPrime0, a0 = 0;

@@ -9,3 +11,3 @@ function zoom(a_lo, a_high, phi_lo) {

weightedSum(next.x, 1, current.x, a, pk), phi = next.fx = f(next.x, next.fxprime),
phiPrime = dot(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || phi >= phi_lo) a_high = a; else {
phiPrime = dotProduct(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || phi >= phi_lo) a_high = a; else {
if (Math.abs(phiPrime) <= -c2 * phiPrime0) return a;

@@ -19,3 +21,3 @@ phiPrime * (a_high - a_lo) >= 0 && (a_high = a_lo), a_lo = a, phi_lo = phi;

if (weightedSum(next.x, 1, current.x, a, pk), phi = next.fx = f(next.x, next.fxprime),
phiPrime = dot(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || iteration && phi >= phi_old) return zoom(a0, a, phi_old);
phiPrime = dotProduct(next.fxprime, pk), phi > phi0 + c1 * a * phiPrime0 || iteration && phi >= phi_old) return zoom(a0, a, phi_old);
if (Math.abs(phiPrime) <= -c2 * phiPrime0) return a;

@@ -22,0 +24,0 @@ if (phiPrime >= 0) return zoom(a, a0, phi);

@@ -64,2 +64,3 @@ export declare const epsilon = 1e-12;

}): number;
export declare function dotProduct(a: number[] | Float32Array, b: number[] | Float32Array): number;
export declare function fuzzyEqualNumber(a: number, b: number): boolean;

@@ -66,0 +67,0 @@ export declare function fuzzyEqualVec(a: vec2, b: vec2): boolean;

@@ -65,2 +65,8 @@ export const epsilon = 1e-12;

export function dotProduct(a, b) {
let ret = 0;
for (let i = 0; i < a.length; ++i) ret += a[i] * b[i];
return ret;
}
export function fuzzyEqualNumber(a, b) {

@@ -67,0 +73,0 @@ return abs(a - b) < 1e-12;

{
"name": "@visactor/vutils",
"version": "0.18.2-alpha.0",
"version": "0.18.2",
"main": "cjs/index.js",

@@ -30,6 +30,6 @@ "module": "es/index.js",

"@types/node": "*",
"@internal/eslint-config": "0.0.1",
"@internal/bundler": "0.0.1",
"@internal/ts-config": "0.0.1",
"@internal/jest-config": "0.0.1"
"@internal/jest-config": "0.0.1",
"@internal/eslint-config": "0.0.1"
},

@@ -36,0 +36,0 @@ "dependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc