# Language: "tensor" vs "array"

**URL:** <https://discourse.julialang.org/t/language-tensor-vs-array/96590>\
**Category:** General Usage\
**Tags:** question, arrays, tensors, english\
**Created:** [March 25, 2023, 10:07am UTC](https://discourse.julialang.org/t/language-tensor-vs-array/96590 "2023-03-25T10:07:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [March 25, 2023, 10:07am UTC](https://discourse.julialang.org/t/language-tensor-vs-array/96590/1 "2023-03-25T10:07:22Z")

</div>

When (in which situations) would you employ the word “tensor” and when instead you would stick to “array” to describe a generic n-dimensional “matrix”, for example to describe your API ?

---

<div class="post-metadata">

**Author:** ![Samuel3008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuel3008/32/25021_2.png) [@Samuel3008](https://discourse.julialang.org/u/Samuel3008)\
**Post date:** [March 25, 2023, 10:16am UTC](https://discourse.julialang.org/t/language-tensor-vs-array/96590/2 "2023-03-25T10:16:24Z")

</div>

I’d use “tensor” only for objects representing a [mathematical tensor](https://en.wikipedia.org/wiki/Tensor). An “array” is an n-dimensional generalization of a matrix (i.e. an arrangement of numbers).

---

<div class="post-metadata">

**Author:** ![nchisholm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nchisholm/32/37414_2.png) [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Post date:** [March 26, 2023, 2:10am UTC](https://discourse.julialang.org/t/language-tensor-vs-array/96590/3 "2023-03-26T02:10:44Z")

</div>

Agreeing with @Samuel3008. From my understanding, tensors can be _represented_ in a particular coordinate system by an array. Tensors are more abstract though, and they follow rules that make them invariant in the choice of coordinate system (Cartesian, polar, curvilinear…).

I know the ML community has adopted the word “tensor”, although I’m not sure if the word is used in the same sense as in math and physics as it is not my field.

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [March 26, 2023, 7:43am UTC](https://discourse.julialang.org/t/language-tensor-vs-array/96590/4 "2023-03-26T07:43:04Z")

</div>

There are a couple of 2 nice discussions [here](https://math.stackexchange.com/questions/1134809/are-there-any-differences-between-tensors-and-multidimensional-arrays) and [here](https://math.stackexchange.com/questions/10282/an-introduction-to-tensors).  
Before today my thought was like in one of the answers there, with `array` be the _computer implementation_ of the mathematical concept of `tensor`, but it seems I was wrong.

Thanks everyone for the clarification.

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [March 26, 2023, 2:14pm UTC](https://discourse.julialang.org/t/language-tensor-vs-array/96590/5 "2023-03-26T14:14:03Z")

</div>

I agree with the above responses. I would avoid the Python-ism of calling an n-dimensional array a tensor, unless it truly is an array representation of an abstract tensor. I think it’s common in Python/ML to sandwich together loosely related matrices along additional dimensions and call that a tensor, even though it most definitely is not a tensor.

---

<div class="post-metadata">

**Author:** ![NiclasMattsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niclasmattsson/32/21988_2.png) [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Post date:** [March 27, 2023, 10:08am UTC](https://discourse.julialang.org/t/language-tensor-vs-array/96590/6 "2023-03-27T10:08:02Z")

</div>

Another +1 here. Just want to add that Wikipedia now has [another tensor page](https://en.wikipedia.org/wiki/Tensor_(machine_learning)) describing the Python/ML meaning of the word. I hate when perfectly well-defined terms get co-opted and misused by a large community, because it causes great confusion and we end up needing to define new words to disambiguate. _Literally_ makes my mind explode.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [March 27, 2023, 12:23pm UTC](https://discourse.julialang.org/t/language-tensor-vs-array/96590/7 "2023-03-27T12:23:21Z")

</div>

> [@CameronBieganek](#):
>
> I would avoid the Python-ism

I don’t think Python has anything to do with this terminology other than much machine learning being done in Python.

For some earlier discussion about the meaning of tensor, see (parts of) [Comparison of tensor packages?](https://discourse.julialang.org/t/comparison-of-tensor-packages/11425).

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [March 27, 2023, 3:12pm UTC](https://discourse.julialang.org/t/language-tensor-vs-array/96590/8 "2023-03-27T15:12:32Z")

</div>

For this matter, I actually don’t like to call 1- or 2-dimensional arrays “vectors” or “matrices” unless they represent a linear-algebraic object. Practically, however, I’ll admit of often do, given that these are the sanctioned names in Julia.

It would be somewhat inconvenient from where we are now (and impossible during v1.x), but I would advocate that linear-algebraic objects be thin wrappers over arrays. It would make excising the `LinearAlgebra` standard library waaaaay easier, which would be a notable savings from startup.

I also have issues with the semantic conflation of arrays and vectors/matrices. We have a lot of functions that work on both but some don’t make sense for one or the other. Sorting elements of vectors/matrices makes no sense, while sorting arrays is totally fine. Arrays don’t have norms, but vectors/matrices do. There are a small number of places (I wish I could remember a few right now) where this conflation produces real conflict.
