當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ndarray.set函數代碼示例

本文整理匯總了TypeScript中ndarray.set函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript set函數的具體用法?TypeScript set怎麽用?TypeScript set使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了set函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: testBinary2D

	function testBinary2D(P: ndarray, Q: ndarray, testName: string) {
		for (let i = 0; i < X.shape[0]; ++i) {
			for (let j = 0; j < X.shape[1]; ++j) {
				X.set(i, j, -10000);
				Y.set(i, j, -256);
			}
		}
		t.equals(P.shape[0], Q.shape[0], testName + "; shape[0]");
		t.equals(P.shape[1], Q.shape[1], testName + "; shape[1]");
		for (let i = 0; i < P.shape[0]; ++i) {
			for (let j = 0; j < P.shape[1]; ++j) {
				Q.set(i, j, i * 1000 + j);
				P.set(i, j, 0);
			}
		}
		binary(P, Q, t, P.shape);
		for (let i = 0; i < P.shape[0]; ++i) {
			for (let j = 0; j < P.shape[1]; ++j) {
				if (!(P.get(i, j) === i * 1000 + j + 1001)) {
					t.fail(`${testName}; encountered ${P.get(i, j)} instead of ${(i * 1000 + j + 1001)} at (" + i + "," + j + ")`);
					return;
				}
			}
		}
		t.pass(testName);
	}
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:26,代碼來源:cwise-tests.ts

示例2: testBinary1D

	function testBinary1D(P: ndarray, Q: ndarray, testName: string) {
		t.equals(P.shape[0], Q.shape[0], testName + "; shape");
		for (let i = 0; i < P.shape[0]; ++i) {
			Q.set(i, i);
			P.set(i, 0);
		}
		binary(P, Q, t);
		for (let i = 0; i < P.shape[0]; ++i) {
			if (!(P.get(i) === i + 1001)) {
				t.fail(`${testName}; encountered ${P.get(i)} instead of ${(i + 1001)} at ${i}`);
				return;
			}
		}
		t.pass(testName);
	}
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:15,代碼來源:cwise-tests.ts

示例3: testBinary1D

	function testBinary1D(P: ndarray, Q: ndarray, testName: string) {
		t.equals(P.shape[0], Q.shape[0], testName + "; shape");
		for (let i = 0; i < P.shape[0]; ++i) {
			Q.set(i, i);
			P.set(i, 0);
		}
		binary(P, Q, t);
		for (let i = 0; i < P.shape[0]; ++i) {
			if (!(P.get(i) === i + 1001)) {
				t.fail(testName + "; encountered " + P.get(i) + " instead of " + (i + 1001) + " at " + i);
				return;
			}
		}
		t.pass(testName);
	}
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:15,代碼來源:cwise-tests.ts

示例4: testUnary1D

	function testUnary1D(arr: ndarray, testName: string) {
		for (let i = 0; i < arr.shape[0]; ++i) {
			arr.set(i, i);
		}
		unary(arr);
		for (let i = 0; i < arr.shape[0]; ++i) {
			if (!(arr.get(i) === i + 1)) {
				t.fail(`${testName}; encountered ${arr.get(i)} instead of ${i + 1} at ${i}`);
				return;
			}
		}
		t.pass(testName);
	}
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:13,代碼來源:cwise-tests.ts

示例5: testUnary1D

	function testUnary1D(arr: ndarray, testName: string) {
		for (let i = 0; i < arr.shape[0]; ++i) {
			arr.set(i, i);
		}
		unary(arr);
		for (let i = 0; i < arr.shape[0]; ++i) {
			if (!(arr.get(i) === i + 1)) {
				t.fail(testName + "; encountered " + arr.get(i) + " instead of " + (i + 1) + " at " + i);
				return;
			}
		}
		t.pass(testName);
	}
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:13,代碼來源:cwise-tests.ts

示例6: testUnary2D

	function testUnary2D(arr: ndarray, testName: string) {
		for (let i = 0; i < arr.shape[0]; ++i) {
			for (let j = 0; j < arr.shape[1]; ++j) {
				arr.set(i, j, i + j * arr.shape[0]);
			}
		}
		unary(arr);
		for (let i = 0; i < arr.shape[0]; ++i) {
			for (let j = 0; j < arr.shape[1]; ++j) {
				if (!(arr.get(i, j) === 1 + i + j * arr.shape[0])) {
					t.fail(`${testName}; encountered ${arr.get(i, j)} instead of ${1 + i + j * arr.shape[0]} at (${i},${j})`);
					return;
				}
			}
		}
		t.pass(testName);
	}
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:17,代碼來源:cwise-tests.ts

示例7: testUnary2D

	function testUnary2D(arr: ndarray, testName: string) {
		for (let i = 0; i < arr.shape[0]; ++i) {
			for (let j = 0; j < arr.shape[1]; ++j) {
				arr.set(i, j, i + j * arr.shape[0]);
			}
		}
		unary(arr);
		for (let i = 0; i < arr.shape[0]; ++i) {
			for (let j = 0; j < arr.shape[1]; ++j) {
				if (!(arr.get(i, j) === 1 + i + j * arr.shape[0])) {
					t.fail(testName + "; encountered " + arr.get(i, j) + " instead of " + (1 + i + j * arr.shape[0]) + " at (" + i + "," + j + ")");
					return;
				}
			}
		}
		t.pass(testName);
	}
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:17,代碼來源:cwise-tests.ts


注:本文中的ndarray.set函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。