( ce: ComputeEngine, dtype: DT )
| 11 | import { isSymbol, isNumber } from '../boxed-expression/type-guards.js'; |
| 12 | import { float64HoldsNumber } from '../boxed-expression/constraint-subject.js'; |
| 13 | import { BigDecimal } from '../../big-decimal/index.js'; |
| 14 | import { stripNumericRanges } from '../../common/type/utils.js'; |
| 15 | import { 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). |
| 20 | let _addN: ((...xs: Expression[]) => Expression) | undefined; |
| 21 | export 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 */ |
| 33 | export 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': |
no outgoing calls
no test coverage detected