# Using ITensor with Big data types

**URL:** <https://itensor.discourse.group/t/using-itensor-with-big-data-types/1386>\
**Category:** ITensor Julia Questions\
**Tags:** julia\
**Created:** [January 3, 2024, 7:01pm UTC](https://itensor.discourse.group/t/using-itensor-with-big-data-types/1386 "2024-01-03T19:01:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![OunchPunch](https://avatars.discourse-cdn.com/v4/letter/o/c89c15/32.png) [@OunchPunch](https://itensor.discourse.group/u/OunchPunch)\
**Post date:** [January 3, 2024, 7:01pm UTC](https://itensor.discourse.group/t/using-itensor-with-big-data-types/1386/1 "2024-01-03T19:01:57Z")

</div>

Hello

I am trying to use ITensor with BigFloats but ran into trouble.  
My understanding is that QR, SVD BLAS decomposition do not support Big data types.  
Is there a simple workaround for this?  
Thanks,  
Ron

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [January 4, 2024, 1:19am UTC](https://itensor.discourse.group/t/using-itensor-with-big-data-types/1386/2 "2024-01-04T01:19:37Z")

</div>

You can try [GitHub - JuliaLinearAlgebra/GenericLinearAlgebra.jl: Generic numerical linear algebra in Julia](https://github.com/JuliaLinearAlgebra/GenericLinearAlgebra.jl/).

---

<div class="post-metadata">

**Author:** ![OunchPunch](https://avatars.discourse-cdn.com/v4/letter/o/c89c15/32.png) [@OunchPunch](https://itensor.discourse.group/u/OunchPunch)\
**Post date:** [January 4, 2024, 5:15pm UTC](https://itensor.discourse.group/t/using-itensor-with-big-data-types/1386/3 "2024-01-04T17:15:27Z")

</div>

Thanks Matt. I added GenericLinearAlgebra.jl and verified that I can do, for example, qr decomposition of a BigFloat ITensor successfully.  
However, something still goes wrong internally in ITensor, for example, when calling orthognalize! (after getting to the qr step) or even simply randomMPS(BigFloat,sites).

A minimal example that fails ( ERROR: UndefRefError: access to undefined reference)

> using GenericLinearAlgebra  
> using ITensors
> 
> sites = siteinds(“S=1/2”,20)  
> psi = randomMPS(BigFloat,sites)

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [January 4, 2024, 5:19pm UTC](https://itensor.discourse.group/t/using-itensor-with-big-data-types/1386/4 "2024-01-04T17:19:01Z")

</div>

I’m sure there isn’t some fundamental reason why we couldn’t get this to work, I think we would just have to work through whatever errors come up. I think @kmp5 may have looked into this a bit.

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [January 4, 2024, 5:22pm UTC](https://itensor.discourse.group/t/using-itensor-with-big-data-types/1386/5 "2024-01-04T17:22:20Z")

</div>

We’re currently in the middle of a big rewrite of the NDTensors.jl backend library which implements the tensor operations used by ITensors.jl, it’s meant to be better organized and designed in general and handle generic code like different GPU and element type backends better than the current NDTensors.jl library. Perhaps some of this will “just work” when that rewrite is done. Additionally, it could just be an issue with `GenericLinearAlgebra`.

---

<div class="post-metadata">

**Author:** ![kmp5](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/kmp5/32/251_2.png) [@kmp5](https://itensor.discourse.group/u/kmp5)\
**Post date:** [January 5, 2024, 8:16pm UTC](https://itensor.discourse.group/t/using-itensor-with-big-data-types/1386/6 "2024-01-05T20:16:36Z")

</div>

HI all,

I looked into this issue and I actually think its related to how `similar` is defined for `Vector{BigFloat}`. What I find in the `randomMPS` call is that in a vector is found with the value `#undef` in it during a tensor contraction. This value is created when the output tensor is constructed using the `similar` function. One can replicate the issue if you create a random vector with `BigFloat` and call similar

```auto
julia> v = rand(BigFloat, 2)
2-element Vector{BigFloat}:
 0.7932223068084634055126420356515827642032940092454878995803670700823602621985869
 0.3994045593624575179130005256984561161320862778997074592614683047941870161467713

julia> similar(v)
2-element Vector{BigFloat}:
 #undef
 #undef

```

This is different from the other element types which fill the vector with instances of the `eltype`, for example

```auto
julia> vf = rand(Float32, 2)
2-element Vector{Float32}:
 0.17679101
 0.78237075

julia> similar(vf)
2-element Vector{Float32}:
 2.0111734f-30
 1.0f-45

```

---

<div class="post-metadata">

**Author:** ![OunchPunch](https://avatars.discourse-cdn.com/v4/letter/o/c89c15/32.png) [@OunchPunch](https://itensor.discourse.group/u/OunchPunch)\
**Post date:** [January 5, 2024, 10:07pm UTC](https://itensor.discourse.group/t/using-itensor-with-big-data-types/1386/7 "2024-01-05T22:07:45Z")

</div>

Thanks for looking into it.  
Is there any reason why replacing similar by, say, zero would not work?
