MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / makeTensorField

Function makeTensorField

src/compute-engine/tensor/tensor-fields.ts:13–43  ·  view source on GitHub ↗
(
  ce: ComputeEngine,
  dtype: DT
)

Source from the content-addressed store, hash-verified

11import { isSymbol, isNumber } from '../boxed-expression/type-guards.js';
12import { float64HoldsNumber } from '../boxed-expression/constraint-subject.js';
13import { BigDecimal } from '../../big-decimal/index.js';
14import { stripNumericRanges } from '../../common/type/utils.js';
15import { isComplexInfinityValue } from '../../common/type/types.js';
16
17// Lazy reference to the n-ary `add()` from arithmetic-add.ts, registered by
18// `init-lazy-refs.ts` — a static import here would close a dependency cycle
19// (arithmetic-add → … → tensor-view → tensor-fields).
20let _addN: ((...xs: Expression[]) => Expression) | undefined;
21export function _setFieldAddN(fn: (...xs: Expression[]) => Expression): void {
22 _addN = fn;
23}
24
25/**
26 * The field of the cells of a tensor of type `dtype`.
27 *
28 * When `holdsFloat` is true (a float tensor, see `TensorData.holdsFloat`),
29 * the numeric fields read every cell back as a float, also a cell whose
30 * value is an integer. The `expression` field ignores it.
31 *
32 * @category Tensors */
33export function makeTensorField<DT extends keyof DataTypeMap>(
34 ce: ComputeEngine,
35 dtype: DT,
36 holdsFloat: boolean = false
37): TensorField<DataTypeMap[DT]> {
38 switch (dtype) {
39 case 'float64':
40 case 'float32':
41 case 'int32':
42 case 'uint8':
43 return new TensorFieldNumber(ce, holdsFloat) as unknown as TensorField<
44 DataTypeMap[DT]
45 >;
46 case 'complex128':

Callers 2

constructorFunction · 0.90
expressionAsTensorFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected