当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ndarray类代码示例

本文整理汇总了TypeScript中ndarray的典型用法代码示例。如果您正苦于以下问题:TypeScript ndarray类的具体用法?TypeScript ndarray怎么用?TypeScript ndarray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ndarray类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: tape

tape("fill", (t) => {
	const fill = cwise({
		args: ["index", "array", "scalar"],
		body(idx, out, f) {
			out = f.apply(undefined, idx);
		}
	});

	const xlen = 10;
	const ylen = 5;
	const array = ndarray(new Float32Array(xlen * ylen), [xlen, ylen]);

	fill(array, (row: number, col: number) => {
		return 0;
	});

	for (let i = 0; i < xlen; i++) {
		for (let j = 0; j < ylen; j++) {
			t.equals(array.get(i, j), 0, `fill (${i},${j})`);
		}
	}

	fill(array, (row: number, col: number) => {
		return 10 * (row + col);
	});

	for (let i = 0; i < xlen; i++) {
		for (let j = 0; j < ylen; j++) {
			t.equals(array.get(i, j), 10 * (i + j), `fill (${i},${j})`);
		}
	}

	t.end();
});
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:34,代码来源:cwise-tests.ts

示例2: Int32Array

import * as ndarray from 'ndarray';

const data = new Int32Array(2 * 2 * 2 + 10);
const a = ndarray(data, [2, 2, 2], [1, 2, 4], 5);

console.log(a.data === data);
console.log(a.shape[0] === 2);
console.log(a.shape[1] === 2);
console.log(a.shape[2] === 2);
console.log(a.stride[0] === 1);
console.log(a.stride[1] === 2);
console.log(a.stride[2] === 4);
console.log(a.offset === 5);
console.log(a.dtype === 'int32');
console.log(a.size === 8);
console.log(a.order[0] === 0);
console.log(a.order[1] === 1);
console.log(a.order[2] === 2);
console.log(a.dimension === 3);
console.log(a.set(0, 0, 0, 1) === 1);
console.log(a.get(0, 0, 0) === 1);
console.log(a.index(1, 1, 1) === 12);

const b = a.lo(0, 0, 0).hi(1, 1, 1);
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:24,代码来源:ndarray-tests.ts

示例3: op2block_neg

	t.throws(() => { op2block_neg(ndarray([1, 2, 3, 4, 5, 6], [3, 2]), ndarray([1, 2, 3, 4], [2, 2])); });
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:1,代码来源:cwise-tests.ts

示例4: op2block_pos

	t.throws(() => { op2block_pos(ndarray([1, 2, 3], [3]), ndarray([1, 2, 3, 4, 5, 6], [3, 2])); });
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:1,代码来源:cwise-tests.ts

示例5: op3

	t.throws(() => { op3(ndarray([1, 2], [2]), ndarray([1, 2, 3], [3]), ndarray([1, 2, 3], [3])); });
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:1,代码来源:cwise-tests.ts

示例6: op2

	t.throws(() => { op2(ndarray([1, 2, 3, 4, 5, 6], [3, 2]), ndarray([1, 2, 3], [3, 1])); });
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:1,代码来源:cwise-tests.ts


注:本文中的ndarray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。