# 1x1 Matrix automatically converted to number

**URL:** https://discourse.julialang.org/t/1x1-matrix-automatically-converted-to-number/101106
**Category:** General Usage
**Tags:** question, linearalgebra
**Created:** [July 3, 2023, 6:36am UTC](https://discourse.julialang.org/t/1x1-matrix-automatically-converted-to-number/101106 "2023-07-03T06:36:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [July 3, 2023, 6:36am UTC](https://discourse.julialang.org/t/1x1-matrix-automatically-converted-to-number/101106/1 "2023-07-03T06:36:49Z")

</div>

I would like

```julia
julia> [1; 0]' * [1 0; 0 2] * [1; 0]
1

```

to return a 1x1 `Matrix`. Is there a more convenient syntax than

```julia
julia> Matrix(transpose([1; 0])) * [1 0; 0 2] * [1; 0]
1-element Vector{Int64}:
 1

```

which still does not return a `Matrix` but a `Vector`.

Ref: [Matrix multiplication with transpose · Issue #512 · JuliaPy/SymPy.jl · GitHub](https://github.com/JuliaPy/SymPy.jl/issues/512)

---

<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: [July 3, 2023, 6:49am UTC](https://discourse.julialang.org/t/1x1-matrix-automatically-converted-to-number/101106/2 "2023-07-03T06:49:46Z")

</div>

```julia
julia> [1;; 0] * [1 0; 0 2] * [1; 0;;]
1×1 Matrix{Int64}:
 1

```

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [July 3, 2023, 6:56am UTC](https://discourse.julialang.org/t/1x1-matrix-automatically-converted-to-number/101106/3 "2023-07-03T06:56:45Z")

</div>

… and it is consistent. Thank you for the reply.

---

<div class="post-metadata">

### Author: ![Tarny\_GG\_Channie](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Tarny\_GG\_Channie](https://discourse.julialang.org/u/Tarny_GG_Channie)
#### Post date: [July 3, 2023, 6:57am UTC](https://discourse.julialang.org/t/1x1-matrix-automatically-converted-to-number/101106/4 "2023-07-03T06:57:36Z")

</div>

```julia
[1 0]*[1 0; 0 2]*[1;0;;]

```

works.  
Be careful about the type of the input.  
Julia doesn’t automatically convert a 1x1 matrix into a number but the type of the inputs in the multiplication was different.
