Variable opsConst

ops: {
    angleBetween: ((u: ad.Num[], v: ad.Num[]) => ad.Num);
    angleFrom: ((u: ad.Num[], v: ad.Num[]) => ad.Num);
    cross2: ((u: ad.Num[], v: ad.Num[]) => ad.Num);
    cross3: ((u: ad.Num[], v: ad.Num[]) => ad.Num[]);
    dist: ((c1: ad.Num, c2: ad.Num) => ad.Num);
    ewmmdiv: ((A1: ad.Num[][], A2: ad.Num[][]) => ad.Num[][]);
    ewmmmul: ((A1: ad.Num[][], A2: ad.Num[][]) => ad.Num[][]);
    ewvvdiv: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[]);
    ewvvmul: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[]);
    mmadd: ((A1: ad.Num[][], A2: ad.Num[][]) => ad.Num[][]);
    mmmul: ((A: ad.Num[][], B: ad.Num[][]) => ad.Num[][]);
    mmsub: ((A1: ad.Num[][], A2: ad.Num[][]) => ad.Num[][]);
    msdiv: ((A: ad.Num[][], c: ad.Num) => ad.Num[][]);
    mtrans: ((A: ad.Num[][]) => ad.Num[][]);
    mvmul: ((A: ad.Num[][], v: ad.Num[]) => ad.Num[]);
    norm: ((c1: ad.Num, c2: ad.Num) => ad.Num);
    rot90: (([x, y]: ad.Num[]) => ad.Num[]);
    smmul: ((c: ad.Num, A: ad.Num[][]) => ad.Num[][]);
    vabs: ((v: ad.Num[]) => ad.Num[]);
    vadd: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[]);
    vdist: ((v: ad.Num[], w: ad.Num[]) => ad.Num);
    vdistsq: ((v: ad.Num[], w: ad.Num[]) => ad.Num);
    vdiv: ((v: ad.Num[], c: ad.Num) => ad.Num[]);
    vdot: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num);
    vmax: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[]);
    vmmul: ((v: ad.Num[], A: ad.Num[][]) => ad.Num[]);
    vmove: ((v: ad.Num[], c: ad.Num, u: ad.Num[]) => ad.Num[]);
    vmul: ((c: ad.Num, v: ad.Num[]) => ad.Num[]);
    vneg: ((v: ad.Num[]) => ad.Num[]);
    vnorm: ((v: ad.Num[]) => ad.Num);
    vnormalize: ((v: ad.Num[]) => ad.Num[]);
    vnormsq: ((v: ad.Num[]) => ad.Num);
    vouter: ((u: ad.Num[], v: ad.Num[]) => ad.Num[][]);
    vproduct: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[]);
    vrot: (([x, y]: ad.Num[], a: ad.Num) => ad.Num[]);
    vsub: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[]);
    vsum: ((v: ad.Num[]) => ad.Num);
}

Some vector operations that can be used on Num.

Type declaration

  • angleBetween: ((u: ad.Num[], v: ad.Num[]) => ad.Num)

    Return the unsigned angle between vectors u, v, in radians. Assumes that both u and v have nonzero magnitude. The returned value will be in the range [0,pi].

      • (u, v): ad.Num
      • Parameters

        • u: ad.Num[]
        • v: ad.Num[]

        Returns ad.Num

  • angleFrom: ((u: ad.Num[], v: ad.Num[]) => ad.Num)

    Return the signed angle from vector u to vector v, in radians. Assumes that both u and v are 2D vectors and have nonzero magnitude. The returned value will be in the range [-pi,pi].

      • (u, v): ad.Num
      • Parameters

        • u: ad.Num[]
        • v: ad.Num[]

        Returns ad.Num

  • cross2: ((u: ad.Num[], v: ad.Num[]) => ad.Num)

    Return 2D determinant/cross product of 2D vectors

      • (u, v): ad.Num
      • Parameters

        • u: ad.Num[]
        • v: ad.Num[]

        Returns ad.Num

  • cross3: ((u: ad.Num[], v: ad.Num[]) => ad.Num[])

    Return 3D cross product of 3D vectors

      • (u, v): ad.Num[]
      • Parameters

        • u: ad.Num[]
        • v: ad.Num[]

        Returns ad.Num[]

  • dist: ((c1: ad.Num, c2: ad.Num) => ad.Num)

    Return the Euclidean distance between scalars c1, c2.

      • (c1, c2): ad.Num
      • Parameters

        • c1: ad.Num
        • c2: ad.Num

        Returns ad.Num

  • ewmmdiv: ((A1: ad.Num[][], A2: ad.Num[][]) => ad.Num[][])

    Return the elementwise quotient of matrices A1, A2.

      • (A1, A2): ad.Num[][]
      • Parameters

        • A1: ad.Num[][]
        • A2: ad.Num[][]

        Returns ad.Num[][]

  • ewmmmul: ((A1: ad.Num[][], A2: ad.Num[][]) => ad.Num[][])

    Return the elementwise product of matrices A1, A2.

      • (A1, A2): ad.Num[][]
      • Parameters

        • A1: ad.Num[][]
        • A2: ad.Num[][]

        Returns ad.Num[][]

  • ewvvdiv: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[])

    Return the elementwise quotient of vectors v1 and v2.

      • (v1, v2): ad.Num[]
      • Parameters

        • v1: ad.Num[]
        • v2: ad.Num[]

        Returns ad.Num[]

  • ewvvmul: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[])

    Return the elementwise product of vectors v1 and v2.

      • (v1, v2): ad.Num[]
      • Parameters

        • v1: ad.Num[]
        • v2: ad.Num[]

        Returns ad.Num[]

  • mmadd: ((A1: ad.Num[][], A2: ad.Num[][]) => ad.Num[][])

    Return the sum of matrices A1, A2.

      • (A1, A2): ad.Num[][]
      • Parameters

        • A1: ad.Num[][]
        • A2: ad.Num[][]

        Returns ad.Num[][]

  • mmmul: ((A: ad.Num[][], B: ad.Num[][]) => ad.Num[][])

    Return the matrix A multiplied by matrix B.

      • (A, B): ad.Num[][]
      • Parameters

        • A: ad.Num[][]
        • B: ad.Num[][]

        Returns ad.Num[][]

  • mmsub: ((A1: ad.Num[][], A2: ad.Num[][]) => ad.Num[][])

    Return the difference of matrices A1, A2.

      • (A1, A2): ad.Num[][]
      • Parameters

        • A1: ad.Num[][]
        • A2: ad.Num[][]

        Returns ad.Num[][]

  • msdiv: ((A: ad.Num[][], c: ad.Num) => ad.Num[][])

    Return the Matrix A divided by scalar c.

      • (A, c): ad.Num[][]
      • Parameters

        • A: ad.Num[][]
        • c: ad.Num

        Returns ad.Num[][]

  • mtrans: ((A: ad.Num[][]) => ad.Num[][])

    Return the transpose of the matrix A.

      • (A): ad.Num[][]
      • Parameters

        • A: ad.Num[][]

        Returns ad.Num[][]

  • mvmul: ((A: ad.Num[][], v: ad.Num[]) => ad.Num[])

    Return the matrix A multiplied by vector v, i.e., Av.

      • (A, v): ad.Num[]
      • Parameters

        • A: ad.Num[][]
        • v: ad.Num[]

        Returns ad.Num[]

  • norm: ((c1: ad.Num, c2: ad.Num) => ad.Num)

    Return the norm of the 2-vector [c1, c2].

      • (c1, c2): ad.Num
      • Parameters

        • c1: ad.Num
        • c2: ad.Num

        Returns ad.Num

  • rot90: (([x, y]: ad.Num[]) => ad.Num[])

    Rotate a 2D point [x, y] by 90 degrees counterclockwise.

      • ([x, y]): ad.Num[]
      • Parameters

        • [x, y]: ad.Num[]

        Returns ad.Num[]

  • smmul: ((c: ad.Num, A: ad.Num[][]) => ad.Num[][])

    Return the scalar c times the Matrix A.

      • (c, A): ad.Num[][]
      • Parameters

        • c: ad.Num
        • A: ad.Num[][]

        Returns ad.Num[][]

  • vabs: ((v: ad.Num[]) => ad.Num[])

    Return the entrywise absolute value of the vector v

      • (v): ad.Num[]
      • Parameters

        • v: ad.Num[]

        Returns ad.Num[]

  • vadd: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[])

    Return the sum of vectors v1, v2.

      • (v1, v2): ad.Num[]
      • Parameters

        • v1: ad.Num[]
        • v2: ad.Num[]

        Returns ad.Num[]

  • vdist: ((v: ad.Num[], w: ad.Num[]) => ad.Num)

    Return the Euclidean distance between vectors v and w.

      • (v, w): ad.Num
      • Parameters

        • v: ad.Num[]
        • w: ad.Num[]

        Returns ad.Num

  • vdistsq: ((v: ad.Num[], w: ad.Num[]) => ad.Num)

    Return the Euclidean distance squared between vectors v and w.

      • (v, w): ad.Num
      • Parameters

        • v: ad.Num[]
        • w: ad.Num[]

        Returns ad.Num

  • vdiv: ((v: ad.Num[], c: ad.Num) => ad.Num[])

    Return the vector v divided by scalar c.

      • (v, c): ad.Num[]
      • Parameters

        • v: ad.Num[]
        • c: ad.Num

        Returns ad.Num[]

  • vdot: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num)

    Return the dot product of vectors v1, v2. Note: if you want to compute a norm squared, use vnormsq instead, it generates a smaller computational graph

      • (v1, v2): ad.Num
      • Parameters

        • v1: ad.Num[]
        • v2: ad.Num[]

        Returns ad.Num

  • vmax: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[])

    Return the maximum value of each component of the vectors v1 and v2

      • (v1, v2): ad.Num[]
      • Parameters

        • v1: ad.Num[]
        • v2: ad.Num[]

        Returns ad.Num[]

  • vmmul: ((v: ad.Num[], A: ad.Num[][]) => ad.Num[])

    Return the vector v multiplied by matrix A, i.e., v^T A.

      • (v, A): ad.Num[]
      • Parameters

        • v: ad.Num[]
        • A: ad.Num[][]

        Returns ad.Num[]

  • vmove: ((v: ad.Num[], c: ad.Num, u: ad.Num[]) => ad.Num[])

    Return v + c * u.

      • (v, c, u): ad.Num[]
      • Parameters

        • v: ad.Num[]
        • c: ad.Num
        • u: ad.Num[]

        Returns ad.Num[]

  • vmul: ((c: ad.Num, v: ad.Num[]) => ad.Num[])

    Return the vector v multiplied by scalar c.

      • (c, v): ad.Num[]
      • Parameters

        • c: ad.Num
        • v: ad.Num[]

        Returns ad.Num[]

  • vneg: ((v: ad.Num[]) => ad.Num[])

    Return the vector v, scaled by -1.

      • (v): ad.Num[]
      • Parameters

        • v: ad.Num[]

        Returns ad.Num[]

  • vnorm: ((v: ad.Num[]) => ad.Num)

    Return the Euclidean norm of vector v.

      • (v): ad.Num
      • Parameters

        • v: ad.Num[]

        Returns ad.Num

  • vnormalize: ((v: ad.Num[]) => ad.Num[])

    Return the vector v, normalized.

      • (v): ad.Num[]
      • Parameters

        • v: ad.Num[]

        Returns ad.Num[]

  • vnormsq: ((v: ad.Num[]) => ad.Num)

    Return the Euclidean norm squared of vector v.

      • (v): ad.Num
      • Parameters

        • v: ad.Num[]

        Returns ad.Num

  • vouter: ((u: ad.Num[], v: ad.Num[]) => ad.Num[][])

    Return outer product matrix uv^T. Vectors u and v must have the same length.

    NOTE: This functionality is duplicated in outerProduct() from Functions.ts. Since outerProduct has a more directly interpretable name, we may wish to deprecate vouter and move outerProduct into Autodiff.ts in a future release.

      • (u, v): ad.Num[][]
      • Parameters

        • u: ad.Num[]
        • v: ad.Num[]

        Returns ad.Num[][]

  • vproduct: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[])

    Returns the entrywise product of two vectors, v1 and v2

      • (v1, v2): ad.Num[]
      • Parameters

        • v1: ad.Num[]
        • v2: ad.Num[]

        Returns ad.Num[]

  • vrot: (([x, y]: ad.Num[], a: ad.Num) => ad.Num[])

    Rotate a 2D point [x, y] by a degrees counterclockwise.

      • ([x, y], a): ad.Num[]
      • Parameters

        • [x, y]: ad.Num[]
        • a: ad.Num

        Returns ad.Num[]

  • vsub: ((v1: ad.Num[], v2: ad.Num[]) => ad.Num[])

    Return the difference of vectors v1 and v2.

      • (v1, v2): ad.Num[]
      • Parameters

        • v1: ad.Num[]
        • v2: ad.Num[]

        Returns ad.Num[]

  • vsum: ((v: ad.Num[]) => ad.Num)

    Return the sum of elements in vector v.

      • (v): ad.Num
      • Parameters

        • v: ad.Num[]

        Returns ad.Num