Re: [julia-users] What makes a programming language successful?
So Robert Griesemer's points (features important for a new language to be successful) are: 1. clear target 2. solid implementation: language, libraries, and tools 3. market readiness 4. technological breakthrough 5. language features without competitors I think Julia has all of 1 to 4. If I understand correctly, language features without competitors means that there is basically only one way to do a certain thing, not many, so that one doesn't have to make meaningless decisions when implementing an algorithm. I don't think Julia has this; instead of striving for minimalistic clarity only, Julia often seems to cater to the casual script programmer. There's another point that Robert makes on a different slide: he points to two tools, gofmt and gofix, which helped make incompatible changes during development. Apparently, gofmt would change the syntax of existing code (e.g. remove trailing semicolons when they became optional), while gofix would change library APIs when incompatible changes were necessary. Julia has something similar to gofix in @Compat. A tool like gofix is missing -- wouldn't it be nice to be able to automatically convert the array / tuple / Union() / Uint places in the code? Naively, it looks like an easy task to slurp in the syntax tree of a Julia module, do a bit of pattern matching on it, and then dump the updated version. Maybe the automated high-quality human-readable formatting is the missing piece? One would think that this would come in handy at many other occasions as well, for example when debugging macros or generic functions... -erik On Thu, Aug 20, 2015 at 4:22 PM, Waldir Pimenta waldir.pime...@gmail.com wrote: I just watched Robert Griesemer's GopherCon 2015 talk The Evolution of Go https://www.youtube.com/watch?v=0ReKdcpNyQg, and although I believe the whole talk will be quite interesting to many in this list, I wondered particularly if people here would agree with his assessment of What makes a programming language successful?, at 33:00 https://www.youtube.com/watch?v=0ReKdcpNyQgt=33m02s (slide #24 http://talks.golang.org/2015/gophercon-goevolution.slide#24), and whether those Julia ticks those boxes. -- Erik Schnetter schnet...@gmail.com http://www.perimeterinstitute.ca/personal/eschnetter/
Re: [julia-users] throw vs error
Verbosity aside, (which may also be disputable since errors are supposed to be rare...), I still do not see the difference even from reading the constructed examples in the manual: both are examples of functions that are not defined for negative arguments, but in the first case, the function throws an exception, in the second it signals an error. michele On Fri, Aug 21, 2015 at 6:06 PM, Stefan Karpinski ste...@karpinski.org wrote: This is actually an old debate between me and Jeff. The distinction I tried to make was that `throw` should be used with catch as a form of control flow, while `error` should be used when there's an actual error. However, that distinction hasn't stuck, possibly because he never liked it and it's common to see `throw(InexactError())` in Base. We could get rid of `error` but writing `throw(ErrorException(oops))` to throw a simple error seems pretty unpalatable. On Fri, Aug 21, 2015 at 11:53 AM, Isaiah Norton isaiah.nor...@gmail.com wrote: Yes. On Fri, Aug 21, 2015 at 11:51 AM, Michele Zaffalon michele.zaffa...@gmail.com wrote: That is my point: error is the same as throw(ErrorException). Should both co-exist? Is error just a short name for the throw(ErrorException) version? On Fri, Aug 21, 2015 at 5:43 PM, Isaiah Norton isaiah.nor...@gmail.com wrote: `error` is generic, whereas `throw` can raise typed errors, such as DomainError, SimdError, UVError, etc. which may have special handling -- for example, customized `show` methods to print help/suggestions to resolve the specific situation. (see also the examples here: http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-try-catch-statement ) On Fri, Aug 21, 2015 at 11:32 AM, Michele Zaffalon michele.zaffa...@gmail.com wrote: In what cases should one use error() instead of throw()? The manual http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-throw-function is not particular clear about the difference: The error() function is used to produce an ErrorException that interrupts the normal flow of control. Isn't what throw is supposed to do?
[julia-users] Defining composite types with fields that include each other
Hi: I want to define two types, and each will have a field that is the other type. For instance: type Foo bar::Bar otherfield1 otherfield2 end type Bar foo::Foo otherfield1 otherfield2 end The above results in an error when defining Foo because Bar is not defined. I could make the types parametric, and do something like Foo{T}, but I really don't need to, because that field will always be a Bar in my application. This is kind of an odd self-referential like problem, but at the definition step rather than initialization. Is there a way for Julia to know that the definition of the yet undefined type is on the way? Thanks, Paul
[julia-users] How to use multiplication or operation of three dimensional matrix, when change R code to Julia code? It is always error.
R code below changed to Julia code. It is always error. I do not know how to change R code below to Julia code correctly? Thank you. #R code forward - function(G.I,Tr,Pr) { n.samp - dim(G.I)[1] n.mark - dim(G.I)[2] F - G.I F[,1,] - sweep(G.I[,1,],2,Pr,*) for (i in 2:n.mark) { F[,i,] - G.I[,i,]*(F[,i-1,]%*%Tr) S - F[,i,1] + F[,i,2] + F[,i,3] F[,i,] - sweep(F[,i,],1,S,/) } return(F) } #error julia code function forward(GI::Array,Tr::Array,Pr::Array) nsamp = size(GI,1) nmark = size(GI,2) F = GI F[:,1,:] = broadcast(*,Pr,GI[:,1,:]) #error for i=2:nmark F[:,i,:] = GI[:,i,:].*(F[:,i-1,:]*Tr) #error S = F[:,i,1] + F[:,i,2] + F[:,i,3] #error F[:,i,:] = broadcast(/,S',F[:,i,:]) #error end return F end
[julia-users] Weird error in @everywhere begin...end block
I'm reading in an h5 file using the HDF5 package and need to invert it over the first two dimensions after reading it in, and I'm doing so in a @everywhere begin...end block, as the data has to be available on all workers. For some reason, doing both steps within one block fails. This works as expected: nprocs()==CPU_CORES || addprocs(CPU_CORES-1) @everywhere begin using HDF5 data = h5read(myfile.h5, data) end @everywhere begin for i = 1:size(data, 3) data[:, :, i] = data[:, :, i]' end end But this fails: nprocs()==CPU_CORES || addprocs(CPU_CORES-1) @everywhere begin using HDF5 data = h5read(myfile.h5, data) for i = 1:size(data, 3) data[:, :, i] = data[:, :, i]' end end ERROR: error compiling anonymous: unsupported or misplaced expression using in function anonymous in eval at C:\cygwin\home\vagrant\buildbot\slave\package_win8_1-x64\build\base\sysimg.jl:7 in anonymous at multi.jl:1305 in anonymous at multi.jl:855 in run_work_thunk at multi.jl:621 in anonymous at task.jl:855
[julia-users] Definition of equality
How do you define the `==` operator for a new type? If I try and define the `isequal` operator, that definition does not apply to '==': import Base.isequal type inty insideint :: Int end isequal(a :: inty, b :: Int) = a.insideint == b inty(5) == 5# false on Julia Version 0.4.0-dev+6858, Commit dc2be6f (2015-08-20 16:45 UTC) isequal(inty(5), 5) # true
Re: [julia-users] Re: Definition of equality
These days you generally want to overload == rather than isequal. On Fri, Aug 21, 2015 at 9:24 AM, Sisyphuss zhengwend...@gmail.com wrote: They are two different operators. import Base.== type inty insideint :: Int end ==(a :: inty, b :: Int) = a.insideint == b inty(5) == 5 On Friday, August 21, 2015 at 3:10:01 PM UTC+2, Dawid Crivelli wrote: How do you define the `==` operator for a new type? If I try and define the `isequal` operator, that definition does not apply to '==': import Base.isequal type inty insideint :: Int end isequal(a :: inty, b :: Int) = a.insideint == b inty(5) == 5# false on Julia Version 0.4.0-dev+6858, Commit dc2be6f (2015-08-20 16:45 UTC) isequal(inty(5), 5) # true
Re: [julia-users] ode-sundials-events option as in deSolve (R)
One way is with the Sims package. I'm not sure I got everything right with your model. https://tshort.github.io/Sims.jl/ using Sims, Winston function model() # note that the time scale is in hours D = Unknown(10.0, D) A1 = Unknown(A1) rateConstant1 = 3.0 rateConstant2 = 5.0 @equations begin der(D) = -rateConstant1*D der(A1) = rateConstant1*D - rateConstant2*A1 Event(sin(2pi/12 * MTime), # Initiate an event every 12 hours Equation[ reinit(D, D + 10) # add a dosage of 10 ]) end end x = sim(model(), 60); wplot(x) On Thu, Aug 20, 2015 at 8:36 PM, Martin J jmalph...@gmail.com wrote: Hi all, I am trying to use julia ode or sundials for the following simple differential equation. dD = -rateConstant1*D dA1 = rateConstant1*D - rateConstant2*A1 This differential equations explain the disposition of drug in human system. *My question is related to resetting state variable at specified time. * In this example, drug was administered repeatedly every 12 hours for 48 hours. So, I need to add an amount to dD every 12 hour to achieve this. In R and deSolve package, this repeated addition of dose was achieved by using ‘events’ options in ode. (R code attached) dose.events (please refer R code - line 32) object is presented below: var time value method depot0 10 replace depot 12 10 replace depot 24 10 replace depot 36 10 replace depot 48 10 replace With my limited understanding, this ‘events’ option in ode (deSolve), replaces the depot (dD) at these mentioned time with the said value. I am looking for similar option in sundials or julia ode. Could you please guide me with this ? Thanks for your suggestions. regards, Martin
[julia-users] Re: Weird error in @everywhere begin...end block
NB: I just saw a post on the Juno forum http://discuss.junolab.org/t/compile-error-when-using-statement-and-for-loop-are-inside-begin-block/295 about this, so it might just be a Juno issue.
Re: [julia-users] Constructor or convert(), Upper case or lower case
Yes, but I think that window will rapidly be shutting for Julia. It is becoming a victim of it's own success, so many people are seeing the advantages of Julia, even now, while there are still a few warts (which hopefully will get addressed quickly during ArrayMegeddon in 0.5). This has already caused some friction even inside of Julia, where the advantages of 0.4 (even in a somewhat unstable state [rapidly being fixed also]), drive people to use it instead of the stable 0.3 release. On Thursday, August 20, 2015 at 11:21:41 AM UTC-4, Stefan Karpinski wrote: Yes. In old languages, there's no longer any hope of fixing the inconsistencies. On Thursday, August 20, 2015, Sisyphuss zhengw...@gmail.com javascript: wrote: This is the characteristic of a young language, isn't it? On Tuesday, August 18, 2015 at 6:02:36 PM UTC+2, Matt Bauman wrote: On Tuesday, August 18, 2015 at 11:29:00 AM UTC-4, Sisyphuss wrote: My point is these inconsistent rules are very confusing. The experience gained in one type cannot be extrapolated to another. I think most people here will agree with you. The discussion on how to spell conversion and/or construction took 2.5 years and over 100 comments to reach consensus and implement the required code changes to make it happen (see issue #1470). Furthermore, the ability to do this only happened recently, so we're still settling on how to best use these new features. It may be possible to deprecate the lowercase symbol function in favor of Symbol, but that'll cause a decent amount of code churn. `float` is an interesting case as it's regularly used to generically mean: convert to a floating point number *OR* a complex number with floating point components, so that's why it's still here but `int` isn't.
[julia-users] Re: Definition of equality
They are two different operators. import Base.== type inty insideint :: Int end ==(a :: inty, b :: Int) = a.insideint == b inty(5) == 5 On Friday, August 21, 2015 at 3:10:01 PM UTC+2, Dawid Crivelli wrote: How do you define the `==` operator for a new type? If I try and define the `isequal` operator, that definition does not apply to '==': import Base.isequal type inty insideint :: Int end isequal(a :: inty, b :: Int) = a.insideint == b inty(5) == 5# false on Julia Version 0.4.0-dev+6858, Commit dc2be6f (2015-08-20 16:45 UTC) isequal(inty(5), 5) # true
Re: [julia-users] throw vs error
That is my point: error is the same as throw(ErrorException). Should both co-exist? Is error just a short name for the throw(ErrorException) version? On Fri, Aug 21, 2015 at 5:43 PM, Isaiah Norton isaiah.nor...@gmail.com wrote: `error` is generic, whereas `throw` can raise typed errors, such as DomainError, SimdError, UVError, etc. which may have special handling -- for example, customized `show` methods to print help/suggestions to resolve the specific situation. (see also the examples here: http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-try-catch-statement ) On Fri, Aug 21, 2015 at 11:32 AM, Michele Zaffalon michele.zaffa...@gmail.com wrote: In what cases should one use error() instead of throw()? The manual http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-throw-function is not particular clear about the difference: The error() function is used to produce an ErrorException that interrupts the normal flow of control. Isn't what throw is supposed to do?
[julia-users] throw vs error
In what cases should one use error() instead of throw()? The manual http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-throw-function is not particular clear about the difference: The error() function is used to produce an ErrorException that interrupts the normal flow of control. Isn't what throw is supposed to do?
Re: [julia-users] throw vs error
`error` is generic, whereas `throw` can raise typed errors, such as DomainError, SimdError, UVError, etc. which may have special handling -- for example, customized `show` methods to print help/suggestions to resolve the specific situation. (see also the examples here: http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-try-catch-statement ) On Fri, Aug 21, 2015 at 11:32 AM, Michele Zaffalon michele.zaffa...@gmail.com wrote: In what cases should one use error() instead of throw()? The manual http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-throw-function is not particular clear about the difference: The error() function is used to produce an ErrorException that interrupts the normal flow of control. Isn't what throw is supposed to do?
Re: [julia-users] throw vs error
Yes. On Fri, Aug 21, 2015 at 11:51 AM, Michele Zaffalon michele.zaffa...@gmail.com wrote: That is my point: error is the same as throw(ErrorException). Should both co-exist? Is error just a short name for the throw(ErrorException) version? On Fri, Aug 21, 2015 at 5:43 PM, Isaiah Norton isaiah.nor...@gmail.com wrote: `error` is generic, whereas `throw` can raise typed errors, such as DomainError, SimdError, UVError, etc. which may have special handling -- for example, customized `show` methods to print help/suggestions to resolve the specific situation. (see also the examples here: http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-try-catch-statement ) On Fri, Aug 21, 2015 at 11:32 AM, Michele Zaffalon michele.zaffa...@gmail.com wrote: In what cases should one use error() instead of throw()? The manual http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-throw-function is not particular clear about the difference: The error() function is used to produce an ErrorException that interrupts the normal flow of control. Isn't what throw is supposed to do?
Re: [julia-users] throw vs error
This is actually an old debate between me and Jeff. The distinction I tried to make was that `throw` should be used with catch as a form of control flow, while `error` should be used when there's an actual error. However, that distinction hasn't stuck, possibly because he never liked it and it's common to see `throw(InexactError())` in Base. We could get rid of `error` but writing `throw(ErrorException(oops))` to throw a simple error seems pretty unpalatable. On Fri, Aug 21, 2015 at 11:53 AM, Isaiah Norton isaiah.nor...@gmail.com wrote: Yes. On Fri, Aug 21, 2015 at 11:51 AM, Michele Zaffalon michele.zaffa...@gmail.com wrote: That is my point: error is the same as throw(ErrorException). Should both co-exist? Is error just a short name for the throw(ErrorException) version? On Fri, Aug 21, 2015 at 5:43 PM, Isaiah Norton isaiah.nor...@gmail.com wrote: `error` is generic, whereas `throw` can raise typed errors, such as DomainError, SimdError, UVError, etc. which may have special handling -- for example, customized `show` methods to print help/suggestions to resolve the specific situation. (see also the examples here: http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-try-catch-statement ) On Fri, Aug 21, 2015 at 11:32 AM, Michele Zaffalon michele.zaffa...@gmail.com wrote: In what cases should one use error() instead of throw()? The manual http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-throw-function is not particular clear about the difference: The error() function is used to produce an ErrorException that interrupts the normal flow of control. Isn't what throw is supposed to do?
Re: [julia-users] Re: Definition of equality
You want to overload `==`, which automatically defines `isequal`. You may also want to overlad `isless`, which then automatically defines ``, ``, `=`, `=`. -erik On Fri, Aug 21, 2015 at 9:43 AM, Stefan Karpinski ste...@karpinski.org wrote: These days you generally want to overload == rather than isequal. On Fri, Aug 21, 2015 at 9:24 AM, Sisyphuss zhengwend...@gmail.com wrote: They are two different operators. import Base.== type inty insideint :: Int end ==(a :: inty, b :: Int) = a.insideint == b inty(5) == 5 On Friday, August 21, 2015 at 3:10:01 PM UTC+2, Dawid Crivelli wrote: How do you define the `==` operator for a new type? If I try and define the `isequal` operator, that definition does not apply to '==': import Base.isequal type inty insideint :: Int end isequal(a :: inty, b :: Int) = a.insideint == b inty(5) == 5# false on Julia Version 0.4.0-dev+6858, Commit dc2be6f (2015-08-20 16:45 UTC) isequal(inty(5), 5) # true -- Erik Schnetter schnet...@gmail.com http://www.perimeterinstitute.ca/personal/eschnetter/
[julia-users] #newbie - Bounds error
I am trying to write a small script to help my company out. I came across Julia on a web search naturally when looking for more speed. I am just getting my feet wet with programming so please be patient with me. This is one piece of the code that I know is very inefficient, so any help is greatly appreciated. FYI, the final version will include pulling the initial variables from a SQL database that could include 100k records. So basically this code could be ran 100k times in the final version at any time (along with many more calculations). Please comment anywhere I could add more efficiency, because speed is absolutely critical. I have a spreadsheet I can provide that shows the methodology a little clearer if it would help. My main question though is why am I getting the BoundsError()... Thanks for all of the help. qi=3454.0 di=0.6 b=0.9 mnths=600 AI=(1/b)*((1-di)^-b-1) ai=AI/12 q(t)=qi/(1+b*ai*t)^(1/b) Q=[q(t-1) for t=1:3] a=((Q[2]/Q[3])^b-1)/b mOil=zeros(Float64,mnths) #Is it worth creating a function here? mOil[1]=(Q[1]^b/((1-b)*ai))*(Q[1]^(1-b)-Q[2]^(1-b)) mOil[2]=(Q[2]^b/((1-b)*a))*(Q[2]^(1-b)-Q[3]^(1-b)) R=zeros(Float64,mnths) R[1]=mOil[2]/(mOil[2]-mOil[1])+b for i=1:2 R[i+1]=R[1]-i*b end for i=3:600 #Getting a BoundsError() here #mOil[i]=mOil[i-1]*(R[i]/(R[i]-1)) R[i+1]=R[1]-i*b end
[julia-users] Re: #newbie - Bounds error
Ok I got the bounds error figure out. I would still appreciate any feedback you might have. On Friday, August 21, 2015 at 3:37:48 PM UTC-5, Tj Midkiff wrote: I am trying to write a small script to help my company out. I came across Julia on a web search naturally when looking for more speed. I am just getting my feet wet with programming so please be patient with me. This is one piece of the code that I know is very inefficient, so any help is greatly appreciated. FYI, the final version will include pulling the initial variables from a SQL database that could include 100k records. So basically this code could be ran 100k times in the final version at any time (along with many more calculations). Please comment anywhere I could add more efficiency, because speed is absolutely critical. I have a spreadsheet I can provide that shows the methodology a little clearer if it would help. My main question though is why am I getting the BoundsError()... Thanks for all of the help. qi=3454.0 di=0.6 b=0.9 mnths=600 AI=(1/b)*((1-di)^-b-1) ai=AI/12 q(t)=qi/(1+b*ai*t)^(1/b) Q=[q(t-1) for t=1:3] a=((Q[2]/Q[3])^b-1)/b mOil=zeros(Float64,mnths) #Is it worth creating a function here? mOil[1]=(Q[1]^b/((1-b)*ai))*(Q[1]^(1-b)-Q[2]^(1-b)) mOil[2]=(Q[2]^b/((1-b)*a))*(Q[2]^(1-b)-Q[3]^(1-b)) R=zeros(Float64,mnths) R[1]=mOil[2]/(mOil[2]-mOil[1])+b for i=1:2 R[i+1]=R[1]-i*b end for i=3:600 #Getting a BoundsError() here #mOil[i]=mOil[i-1]*(R[i]/(R[i]-1)) R[i+1]=R[1]-i*b end
Re: [julia-users] Constructor or convert(), Upper case or lower case
+1 respellings and renamings that follow from this thread If you know, please provide us with those words/names/symbols in v0.4 today that have capitalizations, spellings, or patternings that are inconsistent with the way very similar role/intent/use/purpose is expressed in better reviewed, more exemplary parts of the language. Best practice in Julia as capitalizes type names and assigns them the role of constructor. Constructor has a specific internal meaning; externally, how users relate with Julia, constructor is understood expansively. This happy duality contributes to her appeal. Best practice capitalizes a name that yields a new occurrence of spelled-the-same type. To reflect best practice: symbol should be renamed Symbol, float should be renamed Float (it is a trimmed form of Float64(x), not of 'smallest FloatN that holds x'). On Friday, August 21, 2015 at 8:59:01 AM UTC-4, Scott Jones wrote: Yes, but I think that window will rapidly be shutting for Julia. It is becoming a victim of it's own success, so many people are seeing the advantages of Julia, even now, while there are still a few warts (which hopefully will get addressed quickly during ArrayMegeddon in 0.5). This has already caused some friction even inside of Julia, where the advantages of 0.4 (even in a somewhat unstable state [rapidly being fixed also]), drive people to use it instead of the stable 0.3 release. On Thursday, August 20, 2015 at 11:21:41 AM UTC-4, Stefan Karpinski wrote: Yes. In old languages, there's no longer any hope of fixing the inconsistencies. On Thursday, August 20, 2015, Sisyphuss zhengw...@gmail.com wrote: This is the characteristic of a young language, isn't it? On Tuesday, August 18, 2015 at 6:02:36 PM UTC+2, Matt Bauman wrote: On Tuesday, August 18, 2015 at 11:29:00 AM UTC-4, Sisyphuss wrote: My point is these inconsistent rules are very confusing. The experience gained in one type cannot be extrapolated to another. I think most people here will agree with you. The discussion on how to spell conversion and/or construction took 2.5 years and over 100 comments to reach consensus and implement the required code changes to make it happen (see issue #1470). Furthermore, the ability to do this only happened recently, so we're still settling on how to best use these new features. It may be possible to deprecate the lowercase symbol function in favor of Symbol, but that'll cause a decent amount of code churn. `float` is an interesting case as it's regularly used to generically mean: convert to a floating point number *OR* a complex number with floating point components, so that's why it's still here but `int` isn't.
Re: [julia-users] Trouble compiling Julia v0.4
You shouldn't need libiconv installed through Homebrew for Julia, I don't think. Unlink libiconv, delete deps/libgit2 and reinstall. Usually when brew doesn't want to link something, it's for a good reason. -E
[julia-users] Re: #newbie - Bounds error
you created R to hold 600 things, things indexable as R[1]..R[600] mnths=600 R=zeros(Float64,mnths) later you bring Julia's attention to R[600+1], just one step 'out of bounds' when i is 600, i+1 is 601 In Julia, the top part of the range is included That loop should be for i in 3:(600-1) R[i+1] = .. end On Friday, August 21, 2015 at 4:37:48 PM UTC-4, Tj Midkiff wrote: I am trying to write a small script to help my company out. I came across Julia on a web search naturally when looking for more speed. I am just getting my feet wet with programming so please be patient with me. This is one piece of the code that I know is very inefficient, so any help is greatly appreciated. FYI, the final version will include pulling the initial variables from a SQL database that could include 100k records. So basically this code could be ran 100k times in the final version at any time (along with many more calculations). Please comment anywhere I could add more efficiency, because speed is absolutely critical. I have a spreadsheet I can provide that shows the methodology a little clearer if it would help. My main question though is why am I getting the BoundsError()... Thanks for all of the help. qi=3454.0 di=0.6 b=0.9 mnths=600 AI=(1/b)*((1-di)^-b-1) ai=AI/12 q(t)=qi/(1+b*ai*t)^(1/b) Q=[q(t-1) for t=1:3] a=((Q[2]/Q[3])^b-1)/b mOil=zeros(Float64,mnths) #Is it worth creating a function here? mOil[1]=(Q[1]^b/((1-b)*ai))*(Q[1]^(1-b)-Q[2]^(1-b)) mOil[2]=(Q[2]^b/((1-b)*a))*(Q[2]^(1-b)-Q[3]^(1-b)) R=zeros(Float64,mnths) R[1]=mOil[2]/(mOil[2]-mOil[1])+b for i=1:2 R[i+1]=R[1]-i*b end for i=3:600 #Getting a BoundsError() here #mOil[i]=mOil[i-1]*(R[i]/(R[i]-1)) R[i+1]=R[1]-i*b end
Re: [julia-users] Constructor or convert(), Upper case or lower case
any chance putting in 'Symbol' with a preferred use warning to (depr..) 'symbol'? On Thursday, August 20, 2015 at 11:21:41 AM UTC-4, Stefan Karpinski wrote: Yes. In old languages, there's no longer any hope of fixing the inconsistencies. On Thursday, August 20, 2015, Sisyphuss zhengw...@gmail.com javascript: wrote: This is the characteristic of a young language, isn't it? On Tuesday, August 18, 2015 at 6:02:36 PM UTC+2, Matt Bauman wrote: On Tuesday, August 18, 2015 at 11:29:00 AM UTC-4, Sisyphuss wrote: My point is these inconsistent rules are very confusing. The experience gained in one type cannot be extrapolated to another. I think most people here will agree with you. The discussion on how to spell conversion and/or construction took 2.5 years and over 100 comments to reach consensus and implement the required code changes to make it happen (see issue #1470). Furthermore, the ability to do this only happened recently, so we're still settling on how to best use these new features. It may be possible to deprecate the lowercase symbol function in favor of Symbol, but that'll cause a decent amount of code churn. `float` is an interesting case as it's regularly used to generically mean: convert to a floating point number *OR* a complex number with floating point components, so that's why it's still here but `int` isn't.
[julia-users] Re: #newbie - Bounds error
Thank you Jeff. On Friday, August 21, 2015 at 3:51:41 PM UTC-5, Jeffrey Sarnoff wrote: you created R to hold 600 things, things indexable as R[1]..R[600] mnths=600 R=zeros(Float64,mnths) later you bring Julia's attention to R[600+1], just one step 'out of bounds' when i is 600, i+1 is 601 In Julia, the top part of the range is included That loop should be for i in 3:(600-1) R[i+1] = .. end On Friday, August 21, 2015 at 4:37:48 PM UTC-4, Tj Midkiff wrote: I am trying to write a small script to help my company out. I came across Julia on a web search naturally when looking for more speed. I am just getting my feet wet with programming so please be patient with me. This is one piece of the code that I know is very inefficient, so any help is greatly appreciated. FYI, the final version will include pulling the initial variables from a SQL database that could include 100k records. So basically this code could be ran 100k times in the final version at any time (along with many more calculations). Please comment anywhere I could add more efficiency, because speed is absolutely critical. I have a spreadsheet I can provide that shows the methodology a little clearer if it would help. My main question though is why am I getting the BoundsError()... Thanks for all of the help. qi=3454.0 di=0.6 b=0.9 mnths=600 AI=(1/b)*((1-di)^-b-1) ai=AI/12 q(t)=qi/(1+b*ai*t)^(1/b) Q=[q(t-1) for t=1:3] a=((Q[2]/Q[3])^b-1)/b mOil=zeros(Float64,mnths) #Is it worth creating a function here? mOil[1]=(Q[1]^b/((1-b)*ai))*(Q[1]^(1-b)-Q[2]^(1-b)) mOil[2]=(Q[2]^b/((1-b)*a))*(Q[2]^(1-b)-Q[3]^(1-b)) R=zeros(Float64,mnths) R[1]=mOil[2]/(mOil[2]-mOil[1])+b for i=1:2 R[i+1]=R[1]-i*b end for i=3:600 #Getting a BoundsError() here #mOil[i]=mOil[i-1]*(R[i]/(R[i]-1)) R[i+1]=R[1]-i*b end
Re: [julia-users] Trouble compiling Julia v0.4
homebrew will generally refuse to install libiconv, since forcing homebrew to install could cause significant issues with other compiles on your machine (like julia) if you've installed homebrew in their recommended location of /usr/local. I recommend uninstalling that and deleting the deps/libgit2 folder (to force it to reconfigure). On Fri, Aug 21, 2015 at 10:36 AM vmarsi75-ggroups via julia-users julia-users@googlegroups.com wrote: Hi Folks, I'm having trouble compiling the v0.4 git head: [ 0%] Linking C shared library libgit2.dylib Undefined symbols for architecture x86_64: _libiconv, referenced from: _git_path_iconv in path.c.o _libiconv_close, referenced from: _git_path_direach in path.c.o _git_path_iconv_clear in path.c.o _git_path_diriter_free in path.c.o _git_path_dirload in path.c.o _libiconv_open, referenced from: _git_path_direach in path.c.o _git_path_iconv_init_precompose in path.c.o _git_path_diriter_init in path.c.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[4]: *** [libgit2.0.23.1.dylib] Error 1 make[3]: *** [CMakeFiles/git2.dir/all] Error 2 make[2]: *** [all] Error 2 make[1]: *** [libgit2/build/libgit2.dylib] Error 2 make: *** [julia-deps] Error 2 I'm on OS X Mountain Lion (10.8.5). I've tried to install and link the homebrew libiconv: brew install libiconv brew link libiconv --force but that doesn't work either. The compile goes just fine if I use the release-0.3 branch (without the homebrew libiconv). Any pointers? Thanks, Ravi
[julia-users] Loading a module in Julia v0.4
I tried searching around the group and I couldn't really find what I was looking for. I'm running the following Julia version on Windows: Julia Version 0.4.0-dev+6859 Commit 92ddae7 (2015-08-20 19:38 UTC) Platform Info: System: Windows (x86_64-w64-mingw32) CPU: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz WORD_SIZE: 64 BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell) LAPACK: libopenblas LIBM: libopenlibm LLVM: libLLVM-3.3 In a folder testjulia, I have two files: a.jl and test.jl a.jl: module a function fun(x,y) return x+y end end test.jl: using a println(a.fun(3,5)) When I run include(test.jl) after changing the directory to testjulia in the Julia repl, I get the following error: ERROR: LoadError: ArgumentError: a not found in path in require at loading.jl:196 in include at boot.jl:259 in include_from_node1 at loading.jl:267 while loading C:\Users\***\Documents\testjulia\test.jl, in expression starting on line 1 This behavior does not occur when using Julia v0.3. I thought Base.require() would also search in the current directory for a file named a.jl to search for module a and load it. What would be the correct way to make a module and load it as in the example above? Thanks!
[julia-users] Re: Splitting a multidimensional function
Here is a fun and possibly useful solution (that works only on 0.4 due to call overloading): https://gist.github.com/dpsanders/d8ef239ec8c78c4debee It introduces a `MultidimFunction` type, and a macro `@multidim` that works as follows: julia @multidim f(x) = [sqrt(x[1]), 2x[2]] MultidimFunction([(anonymous function),(anonymous function)]) julia f([1., 2.]) 2-element Array{Float64,1}: 1.0 4.0 julia x = [1., 2.] 2-element Array{Float64,1}: 1.0 2.0 julia f(x) 2-element Array{Float64,1}: 1.0 4.0 julia f[1](x) 1.0 julia f[2](x) 4.0 julia y = [-1., 2.] 2-element Array{Float64,1}: -1.0 2.0 julia f[1](y) ERROR: DomainError: sqrt will only return a complex result if called with a complex argument. try sqrt (complex(x)) in sqrt at ./math.jl:144 in anonymous at /Users/dsanders/.julia/v0.3/ValidatedNumerics/src/multidim/multidim_functions.jl:49 julia f[2](y) 4.0 David.
[julia-users] Re: #newbie - Bounds error
You are welcome, please call me Jeffrey. I can give you a few first impressions. Usespace,itfreesyouandinformsme: == Use space, it frees you and informs me: R[1]=mOil[2]/(mOil[2]-mOil[1])+b == R[1] = mOil[2]/(mOil[2] - mOil[1]) + b Time wells in loops, any savings inside a 600x loop is 600 of the same thing each outside the loop. You can lift any unchanging indirect references out of loops: firstR = mOil[2]/(mOil[2] - mOil[1]) + b R[1] = firstR (loop) R[i+1] = firstR - i*b end Yes is the way to answer Should this be a function instead of the more difficult to follow way that it is inlined here? My guide to naming functions: use names with words or obvious shortenings and choose names that will make sense this time next year and others can follow. Julia really does go fast. It is important to follow the guidelines: performance-tips http://julia.readthedocs.org/en/latest/manual/performance-tips/ and (after that) fast numerics http://julialang.org/blog/2013/09/fast-numeric/ . And this, from the collective wisdom: get it right then get it fast Feedback On Friday, August 21, 2015 at 5:01:49 PM UTC-4, Tj Midkiff wrote: Thank you Jeff. On Friday, August 21, 2015 at 3:51:41 PM UTC-5, Jeffrey Sarnoff wrote: you created R to hold 600 things, things indexable as R[1]..R[600] mnths=600 R=zeros(Float64,mnths) later you bring Julia's attention to R[600+1], just one step 'out of bounds' when i is 600, i+1 is 601 In Julia, the top part of the range is included That loop should be for i in 3:(600-1) R[i+1] = .. end On Friday, August 21, 2015 at 4:37:48 PM UTC-4, Tj Midkiff wrote: I am trying to write a small script to help my company out. I came across Julia on a web search naturally when looking for more speed. I am just getting my feet wet with programming so please be patient with me. This is one piece of the code that I know is very inefficient, so any help is greatly appreciated. FYI, the final version will include pulling the initial variables from a SQL database that could include 100k records. So basically this code could be ran 100k times in the final version at any time (along with many more calculations). Please comment anywhere I could add more efficiency, because speed is absolutely critical. I have a spreadsheet I can provide that shows the methodology a little clearer if it would help. My main question though is why am I getting the BoundsError()... Thanks for all of the help. qi=3454.0 di=0.6 b=0.9 mnths=600 AI=(1/b)*((1-di)^-b-1) ai=AI/12 q(t)=qi/(1+b*ai*t)^(1/b) Q=[q(t-1) for t=1:3] a=((Q[2]/Q[3])^b-1)/b mOil=zeros(Float64,mnths) #Is it worth creating a function here? mOil[1]=(Q[1]^b/((1-b)*ai))*(Q[1]^(1-b)-Q[2]^(1-b)) mOil[2]=(Q[2]^b/((1-b)*a))*(Q[2]^(1-b)-Q[3]^(1-b)) R=zeros(Float64,mnths) R[1]=mOil[2]/(mOil[2]-mOil[1])+b for i=1:2 R[i+1]=R[1]-i*b end for i=3:600 #Getting a BoundsError() here #mOil[i]=mOil[i-1]*(R[i]/(R[i]-1)) R[i+1]=R[1]-i*b end
[julia-users] Difference between ascii(foobar) and simply foobar?
I noticed 3 lines had been changed in the test files I was working on, and it didn't make any sense to me. I thought that ascii(literalstring) where literal string only had ASCII characters, and was already ASCIIString type, would be a no-op, but somebody who I think should know made the change, so I'm confused. Help?