# Efficient creation of power series matrix or array of arrays

**URL:** https://discourse.julialang.org/t/efficient-creation-of-power-series-matrix-or-array-of-arrays/18988
**Category:** Performance
**Tags:** question
**Created:** [December 26, 2018, 1:32am UTC](https://discourse.julialang.org/t/efficient-creation-of-power-series-matrix-or-array-of-arrays/18988 "2018-12-26T01:32:49Z")
**Posts on this page:** 1
**Showing post:** 18

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [March 26, 2019, 10:03pm UTC](https://discourse.julialang.org/t/efficient-creation-of-power-series-matrix-or-array-of-arrays/18988/18 "2019-03-26T22:03:50Z")

</div>

> [@areida](#):
>
> and I call in Julia `matrix_vandermonde(???)` what should I write to have any effect execpt `matrix_vandermonde (generic function with 2 methods)`

First, the code you quoted (remember to [quote your code](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530)!) isn’t correct: you can’t create an array with `Array(m,n)` because you have to give an element type. In this case, since you probably want to have the same element type as `x`, you could change the line `V = Array(m, n)` to

```julia
V = similar(x, m, n)

```

Then you call it by passing an array (for the `x`) argument, and it makes a Vandermonde matrix from that array, for example:

```julia
julia> matrix_vandermonde([1,2,3,4])
4×4 Array{Int64,2}:
 1 1 1 1
 1 2 4 8
 1 3 9 27
 1 4 16 64

```

---

_[View the full topic](https://discourse.julialang.org/t/efficient-creation-of-power-series-matrix-or-array-of-arrays/18988)._
