function rdivide
rdivide(
x: number,
y: number,
): number

Right array division X. / Y.

Divides each element of X by the corresponding element of Y. Inputs X and Y must have the same size.

Examples

Divide two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(5, 6), 0.8333333333333334);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const a = [[5, 6, 5], [7, 8, -1]];
assertEquals(rdivide(a, 3), [[1.6666666666666667, 2, 1.6666666666666667],
 [2.3333333333333335, 2.6666666666666665, -0.3333333333333333]]);

Divide a scalar by a vector

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(3, [-1, -2, -3]), [-3, -1.5, -1]);

Element-wise division of two vectors

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide([5, 6, 7], [-1, -2, -3]), [-5, -3, -2.3333333333333335]);

Element-wise division of two matrices

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];
const f = [[3, 2], [5, 2]];
assertEquals(rdivide(e, f), [[3, 2.5], [1.2, 0.5]]);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];

assertEquals(rdivide(e, 3), [[3, 1.6666666666666667], [2, 0.3333333333333333]]);

Parameters

x: number

The dividend

y: number

The divisor

Return Type

number

The result of the division

Throws

If insufficient arguments are provided or if the input sizes do not match

rdivide(
x: number,
y: array,
): array

Right array division X. / Y.

Divides each element of X by the corresponding element of Y. Inputs X and Y must have the same size.

Examples

Divide two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(5, 6), 0.8333333333333334);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const a = [[5, 6, 5], [7, 8, -1]];
assertEquals(rdivide(a, 3), [[1.6666666666666667, 2, 1.6666666666666667],
 [2.3333333333333335, 2.6666666666666665, -0.3333333333333333]]);

Divide a scalar by a vector

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(3, [-1, -2, -3]), [-3, -1.5, -1]);

Element-wise division of two vectors

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide([5, 6, 7], [-1, -2, -3]), [-5, -3, -2.3333333333333335]);

Element-wise division of two matrices

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];
const f = [[3, 2], [5, 2]];
assertEquals(rdivide(e, f), [[3, 2.5], [1.2, 0.5]]);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];

assertEquals(rdivide(e, 3), [[3, 1.6666666666666667], [2, 0.3333333333333333]]);

Parameters

x: number

The dividend

The divisor

Return Type

The result of the division

Throws

If insufficient arguments are provided or if the input sizes do not match

rdivide(
x: array,
y: number,
): array

Right array division X. / Y.

Divides each element of X by the corresponding element of Y. Inputs X and Y must have the same size.

Examples

Divide two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(5, 6), 0.8333333333333334);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const a = [[5, 6, 5], [7, 8, -1]];
assertEquals(rdivide(a, 3), [[1.6666666666666667, 2, 1.6666666666666667],
 [2.3333333333333335, 2.6666666666666665, -0.3333333333333333]]);

Divide a scalar by a vector

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(3, [-1, -2, -3]), [-3, -1.5, -1]);

Element-wise division of two vectors

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide([5, 6, 7], [-1, -2, -3]), [-5, -3, -2.3333333333333335]);

Element-wise division of two matrices

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];
const f = [[3, 2], [5, 2]];
assertEquals(rdivide(e, f), [[3, 2.5], [1.2, 0.5]]);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];

assertEquals(rdivide(e, 3), [[3, 1.6666666666666667], [2, 0.3333333333333333]]);

Parameters

The dividend

y: number

The divisor

Return Type

The result of the division

Throws

If insufficient arguments are provided or if the input sizes do not match

rdivide(
x: array,
y: array,
): array

Right array division X. / Y.

Divides each element of X by the corresponding element of Y. Inputs X and Y must have the same size.

Examples

Divide two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(5, 6), 0.8333333333333334);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const a = [[5, 6, 5], [7, 8, -1]];
assertEquals(rdivide(a, 3), [[1.6666666666666667, 2, 1.6666666666666667],
 [2.3333333333333335, 2.6666666666666665, -0.3333333333333333]]);

Divide a scalar by a vector

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(3, [-1, -2, -3]), [-3, -1.5, -1]);

Element-wise division of two vectors

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide([5, 6, 7], [-1, -2, -3]), [-5, -3, -2.3333333333333335]);

Element-wise division of two matrices

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];
const f = [[3, 2], [5, 2]];
assertEquals(rdivide(e, f), [[3, 2.5], [1.2, 0.5]]);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];

assertEquals(rdivide(e, 3), [[3, 1.6666666666666667], [2, 0.3333333333333333]]);

Parameters

The dividend

The divisor

Return Type

The result of the division

Throws

If insufficient arguments are provided or if the input sizes do not match

rdivide(
x: number,
y: matrix,
): matrix

Right array division X. / Y.

Divides each element of X by the corresponding element of Y. Inputs X and Y must have the same size.

Examples

Divide two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(5, 6), 0.8333333333333334);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const a = [[5, 6, 5], [7, 8, -1]];
assertEquals(rdivide(a, 3), [[1.6666666666666667, 2, 1.6666666666666667],
 [2.3333333333333335, 2.6666666666666665, -0.3333333333333333]]);

Divide a scalar by a vector

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(3, [-1, -2, -3]), [-3, -1.5, -1]);

Element-wise division of two vectors

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide([5, 6, 7], [-1, -2, -3]), [-5, -3, -2.3333333333333335]);

Element-wise division of two matrices

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];
const f = [[3, 2], [5, 2]];
assertEquals(rdivide(e, f), [[3, 2.5], [1.2, 0.5]]);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];

assertEquals(rdivide(e, 3), [[3, 1.6666666666666667], [2, 0.3333333333333333]]);

Parameters

x: number

The dividend

The divisor

Return Type

The result of the division

Throws

If insufficient arguments are provided or if the input sizes do not match

rdivide(
x: matrix,
y: number,
): matrix

Right array division X. / Y.

Divides each element of X by the corresponding element of Y. Inputs X and Y must have the same size.

Examples

Divide two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(5, 6), 0.8333333333333334);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const a = [[5, 6, 5], [7, 8, -1]];
assertEquals(rdivide(a, 3), [[1.6666666666666667, 2, 1.6666666666666667],
 [2.3333333333333335, 2.6666666666666665, -0.3333333333333333]]);

Divide a scalar by a vector

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(3, [-1, -2, -3]), [-3, -1.5, -1]);

Element-wise division of two vectors

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide([5, 6, 7], [-1, -2, -3]), [-5, -3, -2.3333333333333335]);

Element-wise division of two matrices

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];
const f = [[3, 2], [5, 2]];
assertEquals(rdivide(e, f), [[3, 2.5], [1.2, 0.5]]);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];

assertEquals(rdivide(e, 3), [[3, 1.6666666666666667], [2, 0.3333333333333333]]);

Parameters

The dividend

y: number

The divisor

Return Type

The result of the division

Throws

If insufficient arguments are provided or if the input sizes do not match

rdivide(
x: matrix,
y: matrix,
): matrix

Right array division X. / Y.

Divides each element of X by the corresponding element of Y. Inputs X and Y must have the same size.

Examples

Divide two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(5, 6), 0.8333333333333334);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const a = [[5, 6, 5], [7, 8, -1]];
assertEquals(rdivide(a, 3), [[1.6666666666666667, 2, 1.6666666666666667],
 [2.3333333333333335, 2.6666666666666665, -0.3333333333333333]]);

Divide a scalar by a vector

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide(3, [-1, -2, -3]), [-3, -1.5, -1]);

Element-wise division of two vectors

import { assertEquals } from "jsr:@std/assert";

assertEquals(rdivide([5, 6, 7], [-1, -2, -3]), [-5, -3, -2.3333333333333335]);

Element-wise division of two matrices

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];
const f = [[3, 2], [5, 2]];
assertEquals(rdivide(e, f), [[3, 2.5], [1.2, 0.5]]);

Divide a matrix by a scalar

import { assertEquals } from "jsr:@std/assert";

const e = [[9, 5], [6, 1]];

assertEquals(rdivide(e, 3), [[3, 1.6666666666666667], [2, 0.3333333333333333]]);

Parameters

The dividend

The divisor

Return Type

The result of the division

Throws

If insufficient arguments are provided or if the input sizes do not match

Usage

import rdivide from "elemop/rdivide.ts";