Re: [julia-users] Re: edit() with foreground emacs

2016-04-14 Thread daniel . matz
OK, yeah, I had the same problem when I had EDITOR="emacs -nw", so that it 
didn't launch the GUI but just opened up in the terminal.

Maybe we should make an issue and ask that edit be made a little more 
clever.  In your case, it could perhaps detect that there isn't a windowing 
system available, and then use run instead of spawn.  And in my case, 
perhaps it could notice the -nw flag and use run instead of spawn.

On Thursday, April 14, 2016 at 10:09:55 AM UTC-5, Josef Sachs wrote:
>
> >>>>> On Thu, 14 Apr 2016 07:46:18 -0700 (PDT), daniel matz said: 
>
> > I'm on Mac OS X with Julia 0.4.3.  The edit function is defined in 
> > interactiveutil.jl 
> > <https://github.com/JuliaLang/julia/blob/master/base/interactiveutil.jl>. 
>
>
> > What is the output if you run this at the REPL: 
>
> > Base.editor() 
>
> (when I unset JULIA_EDITOR) 
> Base.editor() == ["emacs"] 
>
> > What happens if you do this at the REPL: 
>
> > run(`emacs Makefile`) 
>
> That runs emacs until I exit it, at which time I am back at the Julia 
> REPL. 
> That is what I want edit() to do. 
>
> > If you notice in the definition of edit that I linked to, when the 
> > editor is emacs, it uses spawn instead of run. 
>
> Yes, that's the problem.  I want emacs to be invoked with run(), not with 
> spawn().  My JULIA_EDITOR=mvim (where mvim is a symbolic link to emacs) 
> kludge works, but it's a kludge. 
>


Re: [julia-users] Re: edit() with foreground emacs

2016-04-14 Thread daniel . matz
I'm on Mac OS X with Julia 0.4.3.

The edit function is defined in interactiveutil.jl 
<https://github.com/JuliaLang/julia/blob/master/base/interactiveutil.jl>.

What is the output if you run this at the REPL:

Base.editor()

What happens if you do this at the REPL:

run(`emacs Makefile`)

If you notice in the definition of edit that I linked to, when the editor 
is emacs, it uses spawn instead of run.

On Wednesday, April 13, 2016 at 4:16:45 PM UTC-5, Josef Sachs wrote:
>
> >>>>> On Wed, 13 Apr 2016 14:03:08 -0700 (PDT), daniel matz said: 
>
> > It seems to work for me.  What were you trying to set JULIA_EDITOR 
> > to when you were trying emacs?  Were you trying to use console emacs 
> > with emacs -nw? 
>
> > On Wednesday, April 13, 2016 at 7:46:21 AM UTC-5, Josef Sachs wrote: 
> >> 
> >> Is there a way that I can use edit() to start emacs in the 
> >> foreground with support for line number? 
> >> 
> >> As a kludge, I am currently setting JULIA_EDITOR=mvim, and I have a 
> >> mvim in my PATH that is a symbolic link to emacs. 
>
> My EDITOR is set to emacs.  I am connected to an Ubuntu system via ssh, 
> with no X Window System.  When I unset JULIA_EDITOR and run julia, 
>
> julia> edit("Makefile") 
> emacs: standard input is not a tty 
>
> Maybe that's what you mean by "console emacs"? 
>
> Are you running the X Window System?  If so, then running emacs in the 
> background would work. 
>


[julia-users] Re: edit() with foreground emacs

2016-04-13 Thread daniel . matz
It seems to work for me.

What were you trying to set JULIA_EDITOR to when you were trying emacs? 
 Were you trying to use console emacs with emacs -nw?

On Wednesday, April 13, 2016 at 7:46:21 AM UTC-5, Josef Sachs wrote:
>
> Is there a way that I can use edit() to start emacs in the foreground 
> with support for line number? 
>
> As a kludge, I am currently setting JULIA_EDITOR=mvim, and I have a 
> mvim in my PATH that is a symbolic link to emacs. 
>


[julia-users] Re: v0.4.3 Generic Linux binaries on CentOS 6

2016-02-02 Thread daniel . matz
Sorry, you asked me to do that earlier, and indeed you are right.  It seems 
that my lab's recent upgrade broke my personal installation of git.

What do you encourage people to do instead of adding to their paths?

Thanks for all of your help, Tony!

On Tuesday, February 2, 2016 at 2:17:18 PM UTC-6, Tony Kelman wrote:
>
> Does your custom installation of git work if you run it outside of Julia? 
> It may be missing some rpaths or LD_LIBRARY_PATH etc. Another data point in 
> why I strongly discourage people from permanently adding things to their 
> paths.
>
>
> On Tuesday, February 2, 2016 at 8:07:39 AM UTC-8, danie...@gmail.com 
> wrote:
>>
>> That was the clue I was needing, thank you.  I had installed git 2.3.3 in 
>> my user directory and had that on my PATH, and so I wasn't getting the 
>> system's installation.  If I use the system's git, things work fine.
>>
>> Any thoughts on why it wasn't working with my installation of git 2.3.3?
>>
>> On Monday, February 1, 2016 at 6:09:17 PM UTC-6, Tony Kelman wrote:
>>>
>>> Where are you getting git from? Can you use git outside of Julia on this 
>>> system? On Julia 0.4 we do not include git in the Linux binaries.
>>>
>>>
>>> On Monday, February 1, 2016 at 12:40:28 PM UTC-8, danie...@gmail.com 
>>> wrote:

 Hello,

 In the past, I've been able to download the generic linux binaries for 
 a release, copy them into my user directory on my organization's lab, and 
 try out Julia without bothering my sys admin.

 I just tried getting the v0.4.3 generic binaries, and I'm now getting 
 an error when I try to use the package manager.

 julia> Pkg.init()
 git: error while loading shared libraries: libcrypto.so.6: cannot open 
 shared object file: No such file or directory
 ERROR: failed process: Process(`git version`, ProcessExited(127)) [127]
  in pipeline_error at process.jl:555
  in readbytes at process.jl:515
  in version at pkg/git.jl:36
  in init at pkg/dir.jl:35
  in init at pkg.jl:19

 The system does have libcrypto.so.10.  Is this just a version issue 
 with this library?

 Thanks!

 Daniel

>>>

[julia-users] Re: v0.4.3 Generic Linux binaries on CentOS 6

2016-02-02 Thread daniel . matz
That was the clue I was needing, thank you.  I had installed git 2.3.3 in 
my user directory and had that on my PATH, and so I wasn't getting the 
system's installation.  If I use the system's git, things work fine.

Any thoughts on why it wasn't working with my installation of git 2.3.3?

On Monday, February 1, 2016 at 6:09:17 PM UTC-6, Tony Kelman wrote:
>
> Where are you getting git from? Can you use git outside of Julia on this 
> system? On Julia 0.4 we do not include git in the Linux binaries.
>
>
> On Monday, February 1, 2016 at 12:40:28 PM UTC-8, danie...@gmail.com 
> wrote:
>>
>> Hello,
>>
>> In the past, I've been able to download the generic linux binaries for a 
>> release, copy them into my user directory on my organization's lab, and try 
>> out Julia without bothering my sys admin.
>>
>> I just tried getting the v0.4.3 generic binaries, and I'm now getting an 
>> error when I try to use the package manager.
>>
>> julia> Pkg.init()
>> git: error while loading shared libraries: libcrypto.so.6: cannot open 
>> shared object file: No such file or directory
>> ERROR: failed process: Process(`git version`, ProcessExited(127)) [127]
>>  in pipeline_error at process.jl:555
>>  in readbytes at process.jl:515
>>  in version at pkg/git.jl:36
>>  in init at pkg/dir.jl:35
>>  in init at pkg.jl:19
>>
>> The system does have libcrypto.so.10.  Is this just a version issue with 
>> this library?
>>
>> Thanks!
>>
>> Daniel
>>
>

[julia-users] v0.4.3 Generic Linux binaries on CentOS 6

2016-02-01 Thread daniel . matz
Hello,

In the past, I've been able to download the generic linux binaries for a 
release, copy them into my user directory on my organization's lab, and try 
out Julia without bothering my sys admin.

I just tried getting the v0.4.3 generic binaries, and I'm now getting an 
error when I try to use the package manager.

julia> Pkg.init()
git: error while loading shared libraries: libcrypto.so.6: cannot open 
shared object file: No such file or directory
ERROR: failed process: Process(`git version`, ProcessExited(127)) [127]
 in pipeline_error at process.jl:555
 in readbytes at process.jl:515
 in version at pkg/git.jl:36
 in init at pkg/dir.jl:35
 in init at pkg.jl:19

The system does have libcrypto.so.10.  Is this just a version issue with 
this library?

Thanks!

Daniel


[julia-users] Re: How to best define an EulerAngles type

2015-08-26 Thread daniel . matz
Josh,

While that would indeed work, I think your function isn't type stable.  I 
think Simon's answer above is the way to go.

Daniel


[julia-users] Re: How to best define an EulerAngles type

2015-08-26 Thread daniel . matz
Thank you all for your responses!

Jeffrey -- Sorry that my wording wasn't clear.  I don't want to extract the 
sequence from the type, I just want to be able to dispatch based on the 
sequence.  My end goal is to have a function that computes a rotation 
tensor from an Euler sequence, and I would need to have a different method 
for each sequence, so it would be handy to be able to dispatch on it.

Tim -- I'm aware of the singularities.  However, Euler angles are still 
used extensively in Aerospace.  For my purposes, the equations of motion 
use a rotation tensor or quaternion internally, but Euler angles are easier 
to visualize and are therefore more convenient for input and output.

Simon -- I'm not sure if I want the EulerAngles type to be mutable or 
immutable.  I definitely planned to look at the types you recommended as I 
continue to tinker.

With Simon's suggested use of call, it looks like my first question (how to 
make a constructor where only the sequence is manually specified) is 
answered.

I guess my only remaining question at the moment is about design.  There 
seem to be several solutions that would all work.  I'm not sure I 
understand the benefits of one over the other.  The options seem to be:

1) A type where the sequence is a member

type EulerAngles{T : Number}
sequence::Int
angles::Vector{T}
end

function rotationtensor{T : Number}(euler::EulerAngles{T})
if euler.sequence == 123
# ...
end
end

2) A type where the sequence is a type parameter

type EulerAngles{s, T : Number}
angles::Vector{T}
end

function rotationtensor{T : Number}(euler::EulerAngles{123, T})
# ...
end

3) A hierarchy of types where the sequence is part of the name of the 
concrete types

abstract EulerAngles{T : Number}

type EulerAngles123{T : Number} : EulerAngles{T}
angles::Vector{T}
end

function rotationtensor{T : Number}(euler::EulerAngles123{T})
# ...
end


[julia-users] How to best define an EulerAngles type

2015-08-25 Thread daniel . matz
Hi, everyone.

I've been tinkering with creating a package for dealing with Euler angles, 
using a very recent build of v0.4.  Rather than just rehash Matlab's 
functions, I wanted to take advantage of the type system, to learn more 
about parametric types and constructors.

I definitely want the Euler rotation sequence and the angles to be bound 
together.  One straightforward way to do this would of course be:

type EulerAngles{T : Number}
seq::Int
angles::Vector{T}
end

Which would work fine, but I'd end up with a huge if block for every valid 
sequence.  So I thought I'd try moving the sequence into the type 
definition.  I think I would declare the type like this:

type EulerAngles{T : Number, s}
angles::Vector{T}
end

But then I can't figure out the best way to provide constructors for this 
type.  What I want is something like this:

EulerAngles{321}([1.0, 2.0, 3.0])

But I can't figure out how to get this to work.  Is this kind of 
constructor even possible with the type I showed above?

I was able to get something very similar to work, by making functions that 
look like constructors with the sequence in their names, like this:

EulerAngles321([1.0, 2.0, 3.0])

Which works, but gives the impression that EulerAngles321 is actually a 
type.  But it seems that typealiases can't have constructors, and I get an 
error trying to define a typealias and a function with the same name.  Even 
with this limitation, though, this seems like an OK solution.

If I really wanted to have types with those names, I could have an abstract 
EulerAngles type, and then have concrete types like EulerAngles321.  But 
that seems like overkill (in terms of the number of types I'd create). 
 Though it would work.

Does anyone have any guidance on how to best approach this?

Thanks for the help!

Daniel


[julia-users] Re: How to best define an EulerAngles type

2015-08-25 Thread daniel . matz
I think the part that is making things difficult for me is that I'm not 
assuming Float64.  I could do it by calling the inner constructor, like you 
do in your example, but I think I'd have to explicitly give the element 
type:

EulerAngles{Float64, 321}([10.0, 20.0, 30.0])

I know that you can use an outer constructor so that the type of the 
arguments determines the type parameter used.  But it isn't clear how to do 
that if the arguments give only a subset of the type parameters, and the 
rest need to be given explicitly.  I was wondering if that is maybe just 
not possible.

In my original post, my [1.0, 2.0, 3.0] array is the Euler angles 
themselves.  I can see how that could be confused for the Euler sequence, 
so here I used [10.0, 20.0, 30.0] instead.

On Tuesday, August 25, 2015 at 11:11:34 PM UTC-5, Jeffrey Sarnoff wrote:

 Are you looking to do this?

 julia type EulerRotation{I,J,K}
   angles::Vector{Float64}
end

 julia function getEulerAngleSeq(x::EulerRotation)
p = typeof(x).parameters
Float64[x.angles[i] for i in p]
end
 getEulerAngleSeq (generic function with 1 method)

 julia testRotSeq321 = EulerRotation{3,2,1}([1.0,2.0,3.0])
 EulerRotation{3,2,1}([1.0,2.0,3.0])

 julia getEulerAngleSeq(testRotSeq321)
 3-element Array{Float64,1}:
  3.0
  2.0
  1.0

 julia testRotSeq132 = EulerRotation{1,3,2}([1.0,2.0,3.0])
 EulerRotation{1,3,2}([1.0,2.0,3.0])

 julia getEulerAngleSeq(testRotSeq132)
 3-element Array{Float64,1}:
  1.0
  3.0
  2.0



 On Tuesday, August 25, 2015 at 11:29:08 PM UTC-4, danie...@gmail.com 
 wrote:

 Hi, everyone.

 I've been tinkering with creating a package for dealing with Euler 
 angles, using a very recent build of v0.4.  Rather than just rehash 
 Matlab's functions, I wanted to take advantage of the type system, to learn 
 more about parametric types and constructors.

 I definitely want the Euler rotation sequence and the angles to be bound 
 together.  One straightforward way to do this would of course be:

 type EulerAngles{T : Number}
 seq::Int
 angles::Vector{T}
 end

 Which would work fine, but I'd end up with a huge if block for every 
 valid sequence.  So I thought I'd try moving the sequence into the type 
 definition.  I think I would declare the type like this:

 type EulerAngles{T : Number, s}
 angles::Vector{T}
 end

 But then I can't figure out the best way to provide constructors for this 
 type.  What I want is something like this:

 EulerAngles{321}([1.0, 2.0, 3.0])

 But I can't figure out how to get this to work.  Is this kind of 
 constructor even possible with the type I showed above?

 I was able to get something very similar to work, by making functions 
 that look like constructors with the sequence in their names, like this:

 EulerAngles321([1.0, 2.0, 3.0])

 Which works, but gives the impression that EulerAngles321 is actually a 
 type.  But it seems that typealiases can't have constructors, and I get an 
 error trying to define a typealias and a function with the same name.  Even 
 with this limitation, though, this seems like an OK solution.

 If I really wanted to have types with those names, I could have an 
 abstract EulerAngles type, and then have concrete types like 
 EulerAngles321.  But that seems like overkill (in terms of the number of 
 types I'd create).  Though it would work.

 Does anyone have any guidance on how to best approach this?

 Thanks for the help!

 Daniel



[julia-users] Re: Pkg.update() inside Julia

2015-03-27 Thread daniel . matz
I had the same issue trying to use Pkg behind a firewall.  I ended up 
changing my git config with the following command:

git config --global url.https://github.com.insteadOf git://github.com


On Friday, March 27, 2015 at 2:39:37 PM UTC-5, Alejandro José C. Somoza 
wrote:

 I run  Pkg.update() and obtain:

 INFO: Initializing package repository C:\Users\asomoza\.julia\v0.3
 INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
 fatal: unable to connect to github.com:
 github.com[0: 192.30.252.130]: errno=No error

 ERROR: failed process: Process(`git clone -q -b metadata-v2 git://
 github.com/Juli
 aLang/METADATA.jl METADATA`, ProcessExited(128)) [128]
  in error at error.jl:22
  in run at process.jl:479
  in anonymous at pkg/dir.jl:46
  in cd at file.jl:30
  in init at pkg/dir.jl:44

 I have a proxy, is any other setting necessary 




[julia-users] Understanding the Cost of Virtualization

2015-03-27 Thread daniel . matz
One of the patterns I use a lot at work is when there are a number of 
options for a certain model, and we want to be able to just select one to 
use.  We also want to be able to change which model is being used part way 
through the overall execution of the code.  In C++, we have an abstract 
base class, and then each model fills in the virtual methods for its 
particular algorithm.  Some manager class keeps a pointer to the base 
class, and we can change that pointer to change the model.

I tried doing this same thing in Julia.  I have a few versions of the code, 
they are all in a gist: 
https://gist.github.com/danielmatz/1a64cded91f996d40b99.

The version slow.jl is the approach I would use in C++.  Since I knew that 
using abstract types directly was a performance hit, I mdd a second 
version, fast.jl, that instead uses an integer flag to indicate which model 
to use.  This second version is 10x faster and uses less memory.

I'm curious about why this performance difference is so pronounced.  What 
exactly is going on that makes virtualization expensive?  The Julia 
dispatch code must be doing something more than how I conceptualize it 
(i.e., as a set of if statements).  I'm just curious what that is.

To try to investigate this, I made yet another version, other.jl (yeah, 
stupid names, sorry), that is like slow.jl, but instead imitates dispatch 
with isa.  Even this is faster, by about 2x!

I'd love to learn more about what is going on in these three cases.  I'm 
also curious if this is something that is expected to get faster in the 
future?

Thanks for the help.  And thanks for being patient with simple minded 
engineers like myself…  Hopefully I didn't screw up the terminology too 
badly.

Daniel


[julia-users] Re: @test_approx_eq results in stack overflow for custom immutable type

2014-07-23 Thread daniel . matz
Wonderful!  Thank you!

The associated problem here is that the error message didn't really help 
me.  I know the developers are busy, but I hope that there's a way to 
eventually improve the error message for this situation.

Thanks again.

Daniel

On Tuesday, July 22, 2014 9:22:31 PM UTC-5, danie...@gmail.com wrote:

 Inspired by the mighty ModInt example, I tried my hand at making a new 
 immutable type.  I wanted to make a FloatingPoint type that won't drift as 
 it gets incremented, for use as a time in an integration loop.  I've 
 attached my code.

 The short story is: I try to compare the type's value to a Float64 literal 
 with @test_approx_eq and I get the following error:

 ERROR: stack overflow
  in = at promotion.jl:170 (repeats 8 times)
 while loading 
 /Users/dmatz/Data/Projects/simulations/julia/time/integer_times_test.jl, in 
 expression starting on line 28


 If I manually convert my type to Float64, it of course works.  I've 
 provided a promote_rule to Float64, which seems to automatically make a lot 
 of operators work.  But why does @test_approx_eq not work?  The stack trace 
 doesn't really help.  I tried to manually do a =, and that works just 
 fine...

 Thanks!

 Daniel



Re: [julia-users] Re: @test_approx_eq results in stack overflow for custom immutable type

2014-07-23 Thread daniel . matz
While I'm not a programming wizard like so many in this community, I do 
hope that the developers are familiar with the interfaces in Go.  I didn't 
see any mention of Go in that issue, though.

I like how in Julia the types and methods are decoupled, in that the 
methods aren't bound to the type, if I'm saying that correctly.  I find my 
thoughts translating to code more naturally than in C++, where everything 
seems to get coupled together.

The way Go does interfaces is kind of analogous to this.  The interfaces 
are defined, but then the types that implement the interface aren't 
specifically declared as such.  The type just has to provide the required 
methods.  It seems so lightweight and natural.

Whatever you all come up with, I'm sure it will be great, if the rest of 
Julia is any indication.

Daniel


[julia-users] Advice for a flight mechanics simulation

2014-07-18 Thread daniel . matz
First, I'm having a blast learning Julia.  Thanks to all those who have 
worked on it.

I'm an aerospace engineer who works on the design and analysis of planetary 
entry vehicles.  Our workhorse tools are flight mechanics/dynamics 
simulations, which at their core just integrate the equations of motion of 
the vehicles.  We make extensive use of Monte Carlo for our analyses.  We 
have historically had a clear separation between the simulation model code 
and the input deck (we still use the term, even though it is originally 
from when my older colleagues were using decks of punch cards to run their 
simulations).  The input deck defines the case to be simulated: how many 
vehicles, the aerodynamic properties of the vehicles, etc.  This clear 
distinction allows us to run a variety of cases with a single set of 
simulation model code.

Our current simulations use C++ for the model code.  The input deck is in 
Python, and has access to the model code thanks to SWIG.  It works pretty 
nicely.

But C++ is daunting to my colleagues (and I grow weary of it myself).  I 
think Julia would be more approachable.  It would also be nice to have the 
input deck and model code be the same language.

So I've started experimenting with making a simple simulation in Julia. 
 I'm having some trouble figuring out the best way to implement some of the 
features, and I was hoping that you might have some advice.

There are two things I'm struggling with.  First, how could I implement our 
input deck concept with Julia?  The main issue I see is that I'd like to 
have a function that performs a single run of the simulation with a 
specified input deck, since that would so easily grow to a Monte Carlo 
capability.  But I can't use include(input_deck.jl) inside a function 
body.  Our input decks can be complex, and we often organize them into 
multiple files, so I'd also like to be able to include those other files 
from within the input deck.  The only way I can think to do this right now 
is to work in the global scope, and then have a second Julia program that I 
can parallelize that would then start a new Julia process to run each case.

Second, the input deck specifies which variables are to be recorded during 
the run.  In C, it's easy to just keep a pointer to a variable and grab 
it's value whenever the data recording code needs it.  In Julia, it seems 
like closures/anonymous functions are probably the best way to do this. 
 That is, in the input deck, the user would do:

# Somewhere earlier in the input deck, the user has done
some_vehicle = new_vehicle()

# Then they set up the data recording
data_record_file = new_data_record_file()
add_variable(data_record_file,()-some_vehicle.some_model.some_variable)

Which I could of course make more convenient with a  macro.  Is there a 
better way?  I was tinkering with using Expressions and automatically 
building the functions (for speed), but that again limits me to working in 
the global scope.

Thank you all for reading such a long post.  I hope my explanation make 
sense, but if not, I'd be happy to attempt to clarify.  I really appreciate 
the help!

Daniel