>
> Semantically, ones(n,1) creates a vector and not a matrix.

I'd rather say that in MATLAB ones(n,1) creates a vector.

This has been discussed many times on the list and in issues. In
particular, see the famous https://github.com/JuliaLang/julia/issues/4774.

In Julia, Vector{T} and Matrix{T} are aliases for Array{T,1} and Array{T,2}
which I think is reasonable. The questions are to what extend a nx1 Matrix
should work similarly to a Vector and a Vector should work similarly to a
nx1 Matrix. That is the discussion in the issue mentioned, and it is
actually more subtle than one would expect.

2014-11-17 12:04 GMT-05:00 Eka Palamadai <[email protected]>:

> Semantically, ones(n,1) creates a vector and not a matrix.
> Why is ones(n,1) different from ones(n)?
> The type system is very confusing and non-intuitive.
>
> On Sunday, November 16, 2014 7:28:28 PM UTC-5, Andreas Noack wrote:
>>
>> The input should be two Vectors, but your first argument is a Matrix
>>
>> 2014-11-16 19:25 GMT-05:00 Eka Palamadai <[email protected]>:
>>
>>> SymTridiagonal does not seem to work properly.
>>>
>>> For e.g, the following snippet fails.
>>>
>>> julia> n=10 ;
>>> A=SymTridiagonal(2*ones(n,1), -1*ones(n-1));
>>> ERROR: `convert` has no method matching convert(::Type{SymTridiagonal{T}},
>>> ::Array{Float64,2}, ::Array{Float64,1})
>>>  in call at base.jl:34
>>>
>>> Any thoughts?
>>>
>>
>>

Reply via email to