Skip to content

add factory methods for Tensor1/2/3 for specified extent#127

Merged
marcelluethi merged 1 commit into
dimwit-dev:mainfrom
marcelluethi:add-tensor-factory-for_extent
Jul 10, 2026
Merged

add factory methods for Tensor1/2/3 for specified extent#127
marcelluethi merged 1 commit into
dimwit-dev:mainfrom
marcelluethi:add-tensor-factory-for_extent

Conversation

@marcelluethi

Copy link
Copy Markdown
Contributor

So far there was an asymmetry when creating Tensors. For general tensors we would write

Tensor(Shape(extent1, ... extentn))

whereas for Tensor1/2/3 we would specify only the axis, but not the full extent:

Tensor1(Axis[1])

The reason is presumably, that the factory was built for initializing tensors from arrays, whose size is already known and hence specifying the extent is redundant.

This PR proposes to add factory methods that take the extent and delegates then to the standard Tensor factories. This makes it possible to create tensors like:

val zeroTensor = Tensor2(Axis[A]->3, Axis[B]->3).fill(0)

@marcelluethi
marcelluethi requested a review from benikm91 July 9, 2026 18:57
@marcelluethi
marcelluethi merged commit f09bcc7 into dimwit-dev:main Jul 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants