On Thu, 2014-07-24 at 22:29 -0700, Ross Boylan wrote:
> Running julia built off git head a few days ago.
>
> julia> counts = Sim.go()
> ERROR: access to undefined reference
> in getindex at array.jl:246
> in go at /home/ross/UCSF/HIVRace/simpleMath.jl:108
>
Perhaps julia has lost track of what's going--optimization?
The accept function uses the global actors variable, and I suspect I
have not set it up properly. If in fact the call into actor was made,
even though not shown in the stack, then maybe it ran into trouble when
it tried to access actors.
const npop = 100 #population size
## lots of other stuff
type Actor
cut :: Vector{FloatingPoint} # track cut point for each time
matches :: Matrix{Int} # 2xtime successful matches with each type
end
Actor() = Actor(zeros(FloatingPoint, nstep), zeros(Int, 2, nstep))
actors = Array(Actor, npop)
First, should that code work?
Second, what is the recommended way to achieve an array of a composite type
with the parts appropriately initialized ("appropriate" = as in the definition
of Actor()).
Thanks.
Ross
P.S. Running via ESS in emacs.
>
> Here's the relevant function, with line 108 indicated
>
> function go()
> global time, actors
> # actors start with default 0 cut
> for time = 1:nstep
> for i = 1:npop
> js = unique(rand(1:npop, ncandidates))
> for j in js
> if i != j && accept(i, j, time) && accept(j, i, time) # 108
> here
> match!(i, j, time)
> end
> end
> end
> end
> counts
> end
>
> 108 doesn't even seem to have an array in it, although this is described as a
> getindex failure.
>
> accept is another function defined in the file.
>
> What's going on?
>
> git branch -v says
> * master d4f8c31 fix one more issue in commit
> 9b5b197695ebe05bb95cf60a0b028e3677529c8f
>
>