# Help with array multiplication

**URL:** <https://discourse.julialang.org/t/help-with-array-multiplication/29611>\
**Category:** New to Julia\
**Created:** [October 7, 2019, 5:39pm UTC](https://discourse.julialang.org/t/help-with-array-multiplication/29611 "2019-10-07T17:39:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)\
**Post date:** [October 7, 2019, 5:39pm UTC](https://discourse.julialang.org/t/help-with-array-multiplication/29611/1 "2019-10-07T17:39:03Z")

</div>

I aware that to multiple arrays, dimensions should match as:  
A: array of (x,y) , B: array of (y,z)

In `Python` below is working fine:

```python
X = np.array([  
        [0,0,1],
        [0,1,1],
        [1,0,1],
        [1,1,1] 
    ])

syn0 = 2*np.random.random((3,1)) - 1

z = np.dot(X,syn0)

```

I tried to replicate it in `Julia` as:

```julia
# input dataset
X = [[0,0,1],
      [0,1,1],
      [1,0,1],
      [1,1,1] 
    ]

syn0 = 2 * rand(3,1)

z = X * syn0

```

But I got the below error:

```bash
DimensionMismatch("matrix A has dimensions (4,1), matrix B has dimensions (3,1)")

```

---

<div class="post-metadata">

**Author:** ![Sebastian\_Rollen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sebastian_rollen/32/7498_2.png) [@Sebastian\_Rollen](https://discourse.julialang.org/u/Sebastian_Rollen)\
**Post date:** [October 7, 2019, 5:53pm UTC](https://discourse.julialang.org/t/help-with-array-multiplication/29611/2 "2019-10-07T17:53:13Z")

</div>

> [@hasanOryx](#):
>
> X = np.array([[0,0,1], [0,1,1], [1,0,1], [1,1,1] ]) syn0 = 2\*np.random.random((3,1)) - 1 z = np.dot(X,syn0)

You’re very close, the issue is in your construction of X. If you instead write it as

```julia
X = [0 0 1
     0 1 1
     1 0 1
     1 1 1]

```

everything else should work:

```julia
julia> z = X * syn0
4×1 Array{Float64,2}:
 0.21256890671577544
 1.1955791336979948 
 1.6645297812021584 
 2.647540008184378

```
