On Wednesday, 2 December 2015 11:38:50 UTC+10, Tim Holy wrote:
>
> Conversely, there are many people who seem to want Julia to treat scalars
> and
> 1-vectors indistinguishably (ala Matlab).
>
Sure, but it should be one way or the other, not half way between. In
Matlab, scalars are literally
Any chance that foldl(vcat,arr_of_arr) will do the job?
On Sunday, 22 November 2015 23:04:26 UTC+10, Cedric St-Jean wrote:
>
> I have a big vector of vectors. Is there any way to vcat/hcat them without
> splatting?
>
> arr_of_arr = Vector[[1],[2,3],[4,5]]
> vcat(arr_of_arr...)
>
> I'm asking
ermutations renamed to something more intuitive, like
> > uniqueperms, or unique_permutations.
> >
> > On Sun, Nov 22, 2015 at 2:16 AM Glen O <gjo...@gmail.com >
> wrote:
> >
> >> While it is true that an interpretation of arrays is multisets, that'
is good. For
> that reason, I would be in favor of permutations remaining as is but having
> multiset_permutations renamed to something more intuitive, like
> uniqueperms, or unique_permutations.
>
> On Sun, Nov 22, 2015 at 2:16 AM Glen O <gjo...@gmail.com >
> wrote:
&g
While it is true that an interpretation of arrays is multisets, that's not
the only reasonable interpretation. And while the strict interpretation of
"permutations" suggests it should include duplicates, you have to consider
what the user would most likely expect it to do. Most would think that
As far as I'm aware, there are two nice ways to tell the comprehension the
type that is going to be returned.
Option 1: Tell it the type of the comprehension:
K = Float64[dot(X[:,i], X[:,j]) for i=1:5, j=1:5]
Option 2: Assert the type of the return of "dot"
K = [dot(X[:,i],X[:,j])::Float64
Does the assertion form work any better?
K=[dot(X[:,i],X[:,j])::Float64 for i=1:5, j=1:5]
On Tuesday, 10 November 2015 02:51:35 UTC+10, rizal zaini wrote:
>
> When I put that code inside a function, I got the same behavior.
>
> For single process, K = Float64[dot(X[:,i], X[:,j]) for i=1:5,
That's the long, complicated way to do it, in my opinion.
An easier approach in the long run would be to simply define a new Array
type (RMArray (for Row Major Array), perhaps), and overload the getindex
and setindex functions for them, etc.
Indeed, perhaps someone could make a package that
There are a few neat ways to make it work nicely. One is to access the
value. That is,
v[2,1]=x[]
Another is to assign as a matrix:
v[2:2,1]=x
Automatic conversion between single-value arrays and numbers could be
problematic, if care isn't taken. For example, what happens if v is an
Array of
But that's true of just about every instance where there are multiple ways
of doing things. vcat vs [;], for instance. In some cases, there are
distinct reasons; in others, there's no functional difference, and it only
exists for the purposes of making it easier to read, for instance. Like
The thing is, it IS an assignment that's going on. In the case of a range,
especially, "for i=1:5" says "loop 5 times, with i=1, then i=2, then i=3,
then i=4, then i=5". "i' is being assigned to on each iteration. Think of
it this way - suppose you were using elementwise operations. You could
An alternative way to read it is "for x equals 1 through 5". It definitely
makes sense for a range. And I don't think anyone has any difficulty
intuitively understanding a for loop using =, even if "in" reads slightly
better.
Incidentally, it's not just Matlab that does it. Most variants of
"When calculating a Fibonacci number, we have to apply F_n=F_(n-1)+F_(n-2)
repeatedly. So to find F_6, we apply the equation for n equals 3 through
6". Writing it as "for n in 3 through 6" or "for n in the range 3 through
6" wouldn't make nearly as much sense.
As I said, for general iterables,
The reason why it's not working is that you're re-assigning x, rather than
editing it. By running "x=x[]", you're creating a copy of x with the
appropriate column removed, and then assigning x to point to the copy,
rather than to the original array.
If you wanted to edit an array's values,
I'm uncertain, but I think I may have figured out what's going on.
The hint lies in the number of allocations - map! has 20 million
allocations, while broadcast! has just 5. So I had a look at how the two
functions are implemented.
map! is implemented in perhaps the simplest way you can think
Seems to be something wrong with the dispatch system with Union...
julia> dispatchtest{T}(x::Union{Array{T,1},T}) = "success"
dispatchtest (generic function with 3 methods)
julia> dispatchtest([1,2])
ERROR: MethodError: `dispatchtest` has no method matching
dispatchtest(::Array{Int64,1})
On
Also note that it's specific to parameterised types.
julia> dispatchtest2(x::Union{Array{Int64,1},Int64}) = "success"
dispatchtest2 (generic function with 2 methods)
julia> dispatchtest2([1,2])
"success"
On Wednesday, 21 October 2015 00:09:42 UTC+10, Glen O wrote:
On Wednesday, 21 October 2015 00:15:41 UTC+10, Matt Bauman wrote:
>
> On Tuesday, October 20, 2015 at 10:09:42 AM UTC-4, Glen O wrote:
>>
>> Seems to be something wrong with the dispatch system with Union...
>>
>
> Yes, Unions with TypeVars can behave strangely when t
I figured I'd post this here before going to github, in case it's a fault
on my end rather than with Julia itself.
I'm trying to use the profiler, and for the most part it seems to work...
somewhat. However, if I try to profile something that takes more than 5-6
seconds, I sometimes get an
This would all be so much easier if we had custom infix operations beyond
the unicode ones.
Just a thought, but what if |> were tweaked to have a ternary form |> (),
so that a|>f(b) automatically gets interpreted as f(a,b)? If you had a
function that outputs a function (say, f(j)=i->i^2+j^2),
Perhaps you could include the function amongst the elements of the type?
immutable MyArray
array::Array
fill::Function
MyArray(array)=new(array,i->fill!(array,i))
end
B=MyArray(zeros(5,2));
B.array
5x2 Array{Float64,2}:
0.0 0.0
0.0 0.0
0.0 0.0
0.0 0.0
0.0 0.0
B.fill(1);
Just to be clear, are you looking for something that will parameterise
across a variety of types, or are you wanting to restrict to a single type?
If the latter, it can be easily done with
function mycode{T}(x::T...)
end
which will make all values in the varargs list the same. To restrict
ts the correct values. So how do I access the types in Tuple{}
> since T[i] will give errors?
>
> On Monday, October 5, 2015 at 11:31:06 AM UTC+1, Glen O wrote:
>>
>> I'll admit, I didn't entirely follow what you're trying to do, but based
>> on what I was able to see, i
lift the functions
> for i in funs
> eval(lift(i, :T1))
> end
>
> Could then do T1(3.4) + 9 and so on for all the functions regardless of
> number of arguments return type etc
>
> DP
>
>
>
>
>
> On Monday, October 5, 2015 at 7:20:55 AM UTC+1, Glen O wrote:
&g
B = (L .== L[1:1])
On Monday, 5 October 2015 22:34:35 UTC+10, Maxim Berman wrote:
>
> Hello,
>
> I tried to use element-wise equality on list-of-lists in julia:
>
> L = Vector{Int}[[1,2],[2,3]]
> B = (L .== L[1])
>
> However, due to .== broadcasting, this last expression performs an
>
I'm assuming that v is an array of vectors. Does this do any better?
N=zeros(length(v[1]),max(length(v[1]),length(v))) # Because there can't be
more than this many columns
i=0
for w=v
if any(w.!=0)&!=N[:,1:i]*(N[:,1:i]\w)
i+=1
N[:,i]=j
end
end
N=N[:,1:i]
Note: may have minor
Is there a reason why the juliareleases ppa couldn't provide a julia0.4
package, separately from the currently julia package? I've seen similar
things done with packages elsewhere, including within the main ubuntu
repositories. Indeed, given the changes happening to the language, perhaps
it's
27 matches
Mail list logo