Skip to content

Scalar multiplication with scalar tensor crashes #111

Description

@MFrankenbach

Description

I seems like the scalar constructor for a Tensor4all.Tensor should have ;kwargs... for compatibility reasons. Currently, multiplication of a scalar tensor by a number fails.

Steps to reproduce

julia> import Tensor4all

julia> t = Tensor4all.Tensor(3.0)
Tensor4all.Tensor{Float64, 0}(Tensor4all.TensorHandle(Ptr{Nothing} @0x000000038d20b1e0), Tensor4all.Index[])

julia> 2 * t
ERROR: MethodError: no method matching Tensor4all.Tensor(::Float64, ::Vector{Tensor4all.Index}; structured_storage::Nothing)
The type `Tensor4all.Tensor` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  Tensor4all.Tensor(::Array{T, N}, ::AbstractVector{Tensor4all.Index}; backend_handle, structured_storage) where {T, N}
   @ Tensor4all ~/.julia/packages/Tensor4all/9dkTQ/src/Core/Tensor.jl:159
  Tensor4all.Tensor(::AbstractArray, ::AbstractVector{Tensor4all.Index}; backend_handle, structured_storage)
   @ Tensor4all ~/.julia/packages/Tensor4all/9dkTQ/src/Core/Tensor.jl:338
  Tensor4all.Tensor(::Number) got unsupported keyword argument "structured_storage"
   @ Tensor4all ~/.julia/packages/Tensor4all/9dkTQ/src/Core/Tensor.jl:350
  ...

Stacktrace:
 [1] *::Int64, t::Tensor4all.Tensor{Float64, 0})
   @ Tensor4all ~/.julia/packages/Tensor4all/9dkTQ/src/Core/Tensor.jl:898
 [2] top-level scope
   @ REPL[48]:1

Actual behavior

see above

Expected behavior

In this example, I expect a Float64 scalar Tensor with value 6 as a result.

Tensor4all.jl version

main/HEAD

Julia version

1.11.7

OS

macOS 14.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingproposedIssue opened, awaiting maintainer review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions