[julia-users] Re: linear algebra question

2016-10-05 Thread James Noeckel
You could iteratively orthogonalize v1 through vn, setting an orthogonal 
distance threshold for when to consider a new vector to be in the span of 
the previous vectors.

On Wednesday, October 5, 2016 at 5:25:26 AM UTC-4, harven wrote:
>
> Is there a way to check if a vector v is in the linear span of a given 
> family of vectors v1,...vn?
> I don't think I saw such a function in the base library but I may have 
> missed it.
>
> I can use something like 
>
>  rank([v;v1...vn]) == rank([v1...vn])
>
> but that looks inefficient. 
>
> Also is there any facility to compute with matrices with integer/rational 
> coefficients?
> It seems that the standard library focuses on floats.
>


Re: [julia-users] Gadfly plots no longer showing in Juno

2016-10-04 Thread James Noeckel
Thanks for the prompt response.

On Tuesday, October 4, 2016 at 2:17:19 PM UTC-4, Mike Innes wrote:
>
> Try Pkg.checkout("Gadfly"). We recently moved the integration code from 
> Atom to Gadfly, but I guess Gadfly hasn't been tagged yet.
>
> On Tue, 4 Oct 2016 at 19:14 James Noeckel <jw...@cornell.edu > 
> wrote:
>
>> With the latest update, it seems that display(::Gadfly.Plot) no longer 
>> opens a plot tab in the Atom editor. Instead, it prints the contents of the 
>> plot object in the console. Gadfly is Juno's preferred plotting 
>> environment, but I don't know if this is an issue with Gadfly.jl or 
>> Atom.jl. Can anybody figure out a workaround?
>>
>

[julia-users] Gadfly plots no longer showing in Juno

2016-10-04 Thread James Noeckel
With the latest update, it seems that display(::Gadfly.Plot) no longer 
opens a plot tab in the Atom editor. Instead, it prints the contents of the 
plot object in the console. Gadfly is Juno's preferred plotting 
environment, but I don't know if this is an issue with Gadfly.jl or 
Atom.jl. Can anybody figure out a workaround?


[julia-users] Error using inner constructors and type parameters

2016-07-09 Thread James Noeckel
type LinkedMesh{RT<:Real}
  faces::LinkedList{LinkedFace}
  vertices::Array{Point{3, RT}, 1}
  LinkedMesh(points::Array{Point{3, RT}, 1}) = new(nil(LinkedFace), points)
end


When I pass the below value to the above constructor, I get an error:
points::AbstractArray{Point{3, FT}, 1} #the value isn't relevant

mesh = LinkedMesh(points)


ERROR: MethodError: `convert` has no method matching 
convert(::Type{Meshing.LinkedMesh{RT<:Real}}, 
::Array{FixedSizeArrays.Point{3,Float64},1})
This may have arisen from a call to the constructor 
Meshing.LinkedMesh{RT<:Real}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, ::T)


This suggests that it isn't using my constructor at all, possibly because 
of the type parameter. But Float64 is a subtype of Real, so I don't see why 
this isn't working.


[julia-users] Value written to file different from value printed

2016-06-17 Thread James Noeckel
This is driving me crazy. In the below code, you can see the print 
statement followed directly by a file write. The default value of the 
variable mhullvol is -1. This is what gets written to the file, despite it 
being assigned a value by that time, as demonstrated by the print, which 
shows 0.827. Is there some behavior I should know about? Is the compiler 
changing the order of execution? Even stranger, this is only happening to 
mhullvol, and none of the other variables.

include("LCIOUtils.jl")
using MeshTools
using LCIOUtils
const globalscale = 0.005

if length(ARGS) != 10
  println("Usage: PROGRAM filename collection startevent endevent resX resY 
resZ blurRadius bufferpercent thresholdPercent")
  exit()
end

filename = ARGS[1]
outputName = match(r".*/(.*).slcio", filename)[1]
collectionname = ARGS[2]
eventstart = parse(Int, ARGS[3])
eventend = parse(Int, ARGS[4])
resX, resY, resZ = parse(Int, ARGS[5]), parse(Int, ARGS[6]), parse(Int, 
ARGS[7])
stdev = parse(Int, ARGS[8])
bufferpercent = parse(Int, ARGS[9])
thresholdPercent = parse(Int, ARGS[10])


type Collector
  offset :: Int
  densityfilename
  ratiofilename
  meshdensityfilename
  energyfilename
  mhullvolumefilename
  Collector(num, offset) = new(offset, 
"output/$(outputName)-$(collectionname)-events_$(eventstart)_to_$(eventend)-$(resX)x$(resY)x$(resZ)-blur_$(stdev)-buffer_$(bufferpercent)-threshold_$(thresholdPercent)-hulldensity.txt",
  
 
"output/$(outputName)-$(collectionname)-events_$(eventstart)_to_$(eventend)-$(resX)x$(resY)x$(resZ)-blur_$(stdev)-buffer_$(bufferpercent)-threshold_$(thresholdPercent)-volumeratio.txt",
  
 
"output/$(outputName)-$(collectionname)-events_$(eventstart)_to_$(eventend)-$(resX)x$(resY)x$(resZ)-blur_$(stdev)-buffer_$(bufferpercent)-threshold_$(thresholdPercent)-meshdensity.txt",
  
 
"output/$(outputName)-$(collectionname)-events_$(eventstart)_to_$(eventend)-$(resX)x$(resY)x$(resZ)-blur_$(stdev)-buffer_$(bufferpercent)-threshold_$(thresholdPercent)-mhullvolume.txt",
  
 
"output/$(outputName)-$(collectionname)-events_$(eventstart)_to_$(eventend)-MCEnergy.txt")
end

import Base.call

function call(collector :: Collector, positions :: Matrix, i :: Int, 
maxEnergy::Float64)
  print("processing event $i")
  mhull_energydensity = -1
  ratio = -1
  mesh_energydensity = -1
  maxEnergy = -1
  mhullvol = -1
  if size(positions)[2] == 0
println("no points to load!")
  else
grid = MeshGrid(resX, resY, resZ, positions, true, stdev, bufferpercent 
/ 100.0)
maxEnergyDensity = maximum(grid.data)
minEnergyDensity = minimum(grid.data)
print(".")

verts, indices = createMesh(grid.data, (grid.maxPt - grid.minPt)..., 
grid.minPt..., (maxEnergyDensity - minEnergyDensity) / 100.0 * 
thresholdPercent + minEnergyDensity, 1, globalscale)
print(".")
verts, indices = removeDoubles(verts, indices)
print(".")
verts_mhull, indices_mhull = convexhull(verts)
print(".")
vol = volume(verts, indices)
mhullvol = volume(verts_mhull, indices_mhull)

totalE = sum(positions[4, :])
mhull_energydensity = totalE/mhullvol
ratio = vol/mhullvol
mesh_energydensity = totalE/vol
print(".\n")

  end

  densityfile = open(collector.densityfilename, "a")
  ratiofile = open(collector.ratiofilename, "a")
  meshdensityfile = open(collector.meshdensityfilename, "a")
  energyfile = open(collector.energyfilename, "a")
  mhullvolumefile = open(collector.mhullvolumefilename, "a")
  write(densityfile, "$(mhull_energydensity)\n")
  write(ratiofile, "$(ratio)\n")
  write(meshdensityfile, "$(mesh_energydensity)\n")
  write(energyfile, "$(maxEnergy)\n")
  println("Hull volume: $(mhullvol)")
  write(mhullvolumefile, "$(mhullvol)\n")

  close(densityfile)
  close(ratiofile)
  close(meshdensityfile)
  close(energyfile)
  close(mhullvolumefile)
end

mappositions(Collector(eventend - eventstart + 1, eventstart-1), filename, 
eventstart, eventend)

As you can see, the print(mhullvol) and write("$(mhullvol)\n") are right 
next to each other, so the discrepancy makes no sense.