Thanks Tim,

I need the single column matrix literal in one place only, so it's not 
worth the use of a function.

But I came to understand that there is no need to have a way to write 
literals for everything, and that the "right/standard/official" way to do 
what I want is in fact the use of reshape.

reshape let us do
    reshape([1, 2, 3], (3,1))
and can be used to any other shapes one can need.
Additionally, we can do
    [1 2 3]'
as a trick.

Thanks!

On Monday, January 27, 2014 11:59:29 AM UTC, Tim Holy wrote:
>
> You have several options, e.g., define a 
>
> colv(v::AbstractVector) = reshape(v, length(v), 1) 
>
> function. Or you can define a comparison function, 
>
> cmpcolv(v1, v2) 
>
> which will do the comparison with what you receive from SymPy, accepting 
> either AbstractVector or AbstractMatrix arguments. 
>
> The latter would be preferable because you can implement it without 
> triggering 
> any memory allocation. 
>
> --Tim 
>
> On Sunday, January 26, 2014 10:47:43 PM Cristóvão Duarte Sousa wrote: 
> > BTW, I need that to compare against a column vector with  2 
> > dimensions received from Python through SymPy.jl. 
> > 
> > It is not a big issue, I can perfectly use [1 2 3]'. 
> > I'm just wondering if it is the best way to do it. 
> > 
> > On Monday, January 27, 2014 6:39:54 AM UTC, Cristóvão Duarte Sousa 
> wrote: 
> > > Hi, 
> > > 
> > > What is the best way to write down a "single column matrix" literal? 
> > > 
> > > For exampe, to obtain this: 
> > >     3x1 Array{Int64,2}:  # 2 dimensions 
> > >     
> > >      1 
> > >      2 
> > >      3 
> > > 
> > > This 
> > > 
> > >     [[1], [2], [3]] 
> > > 
> > > doesn't work, 
> > > this 
> > > 
> > >     [1, 2, 3]'' 
> > > 
> > > works but seems it can stop working in the future 
> > > (#2686<https://github.com/JuliaLang/julia/issues/2686> ), 
> > > and, finally, this 
> > > 
> > >     [1 2 3]' 
> > > 
> > > indeed does what I want. 
> > > However, is it the use of the transpose the only option? 
> > > 
> > > Thanks. 
>

Reply via email to