[julia-users] Re: JuliaCon registrations open

2015-06-03 Thread Jiahao Chen
*Extension of hotel conference pricing*

The Hyatt has generously extended their conference booking rate by one 
week, so that attendees can continue to enjoy the special rate we have 
negotiated for JuliaCon until the end of *June 10*. Anne Beaumont at the 
Hyatt Regency Cambridge will be available to take reservations and 
questions. (Tel: + 1 617.441-6431 Fax: +1 617.441.6489, email: 
anne.beaum...@hyatt.com).

We still have rooms available at the conference rate, which are over 30% 
cheaper than the list rate. Again, I would encourage everyone attending 
from out of town to take advantage of our conference pricing arrangement.

To match the extension in the hotel rate, we will also be extending the 
current JuliaCon registration rates by one week, so that the current early 
bird pricing will also be available until the end of *June 10*.


[julia-users] Re: Error installing GnuTLS

2015-06-03 Thread Glen H
I believe the issue is you are using too old of a gcc compiler.  I think 
you need at least gcc 4.4.

On Wednesday, June 3, 2015 at 4:42:34 PM UTC-4, Samuel Colvin wrote:
>
> Just tried to install Quandl and found GnuTLS won't install, I'm on Ubuntu 
> 15.04, 
>
> version info:
> Julia Version 0.3.8
> Commit 79599ad (2015-04-30 23:40 UTC)
> Platform Info:
>   System: Linux (x86_64-linux-gnu)
>   CPU: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
>   WORD_SIZE: 64
>   BLAS: libopenblas (NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Sandybridge)
>   LAPACK: liblapack.so.3
>   LIBM: libopenlibm
>   LLVM: libLLVM-3.3
>
> Error:
>
> INFO: Cloning cache of GnuTLS from git://github.com/JuliaWeb/GnuTLS.jl.git
> INFO: Installing GnuTLS v0.0.4
> INFO: Building Nettle
> INFO: Building GnuTLS
> INFO: Attempting to Create directory 
> /home/samuel/.julia/v0.3/GnuTLS/deps/downloads
> INFO: Downloading file 
> http://www.lysator.liu.se/~nisse/archive/nettle-2.7.tar.gz
>   % Total% Received % Xferd  Average Speed   TimeTime Time 
>  Current
>  Dload  Upload   Total   SpentLeft 
>  Speed
> 100 1521k  100 1521k0 0   814k  0  0:00:01  0:00:01 --:--:-- 
>  814k
> INFO: Done downloading file 
> http://www.lysator.liu.se/~nisse/archive/nettle-2.7.tar.gz
> INFO: Attempting to Create directory 
> /home/samuel/.julia/v0.3/GnuTLS/deps/src
> INFO: Attempting to Create directory /home/samuel/.julia/v0.3/GnuTLS/deps
> INFO: Directory /home/samuel/.julia/v0.3/GnuTLS/deps already created
> INFO: Attempting to Create directory 
> /home/samuel/.julia/v0.3/GnuTLS/deps/src/nettle-2.7
> INFO: Attempting to Create directory 
> /home/samuel/.julia/v0.3/GnuTLS/deps/builds/nettle
> INFO: Changing Directory to 
> /home/samuel/.julia/v0.3/GnuTLS/deps/builds/nettle
> checking build system type... x86_64-unknown-linux-gnu
> checking host system type... x86_64-unknown-linux-gnu
> checking for -R flag... using -Wl,-rpath,
> Searching for libraries
> checking /home/samuel/.julia/v0.3/GnuTLS/deps/usr/lib... not found
> checking /usr/local/lib... added
> checking /sw/local/lib... not found
> checking /sw/lib... not found
> checking /usr/gnu/lib... not found
> checking /opt/gnu/lib... not found
> checking /sw/gnu/lib... not found
> checking /usr/freeware/lib... not found
> checking /usr/pkg/lib... not found
> checking for gcc... gcc
> checking whether the C compiler works... no
> configure: error: in `/home/samuel/.julia/v0.3/GnuTLS/deps/builds/nettle':
> configure: error: C compiler cannot create executables
>
>
> There then follows a long error from the line which failed (the exit code 
> is 77), but it looks to me like the all the "not found" and the "checking 
> whether the C compiler works... no" are the real error here. I have gcc, 
> build-essential and all the versions of llvm from the aptitude installed. 
> Nettle installed fine before this.
>
> I assume I'm doing/not doing/missing something very dumb?
>
> Is the problem that I need to somehow install llvm-3.3?
>


[julia-users] Understanding abstract parametric type, parameter resolution

2015-06-03 Thread Glen H
Hi,

I'm a bit confused on why the follow code fails:

abstract Country
immutable US  <: Country;  pct::Real end
immutable CA  <: Country;  pct::Real end
immutable DE  <: Country;  pct::Real end

abstract AbstractAsset{Listed<:Country,Origin<:Country}# line 6
type Stock{Listed,Origin} <: AbstractAsset{Listed,Origin}
  listed::Type{Listed} # the country of the exchange (where it was 
purchased)
  origin::Type{Origin} # the country the stocks are from
end

type Account{A<:AbstractAsset} # line 12
  holdings::AbstractVector{A}
end

for stocks in Any[[Stock(US,US)], [Stock(US,US), Stock(US,US)], [Stock(CA, 
US), Stock(CA, CA)]] # line 16
  @show typeof(stocks)
  Account(stocks)
end


The error output is:

typeof(stocks) => Array{Stock{US,US},1}
typeof(stocks) => Array{Stock{US,US},1}
typeof(stocks) => Array{Stock{Listed,Origin},1}
ERROR: `Account{A<:AbstractAsset{Listed<:Country,Origin<:Country}}` has no 
method matching 
Account{A<:AbstractAsset{Listed<:Country,Origin<:Country}}(::Array{Stock{Listed,Origin},1})
 in anonymous at no file:18
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
while loading type_of_types.jl, in expression starting on line 16



The fix seems to be to change line 7 to:

type Stock{Listed<:Country,Origin<:Country} <: AbstractAsset{Listed,Origin}

then the output is:

typeof(stocks) => Array{Stock{US,US},1}
typeof(stocks) => Array{Stock{US,US},1}
typeof(stocks) => Array{Stock{Listed<:Country,Origin<:Country},1}

These changes to line 7 would seem to be redundant because Listed and 
Origin already must be a Country because of line 6 -- I tested setting 
"Stock.listed" to a currency and it indeed fails (as expected because of 
line 6).  I get confused about how the parametric types resolve their types 
and I feel that I'm missing some key concept.  Can someone help me 
understand what is going on here?  Debugging "has no method matching" 
errors comes up quite often for me.

Thanks,

Glen


Re: [julia-users] Re: Generate polynomial expression on the fly

2015-06-03 Thread Júlio Hoffimann
Hi,

I would like to share the solution for my use case with you. I needed the
Vandermonde-ish matrix to implement another method in GeoStats.jl


The multinom_exp()
 returns
the exponents in the multinomial expansion without expression generation. I
then call it inside unikrig()
 to
generate the matrix F.

Questions:

1. Any interest in adding multinom_exp() to Base?
2. Am I using the Julia doc system correctly? I can retrieve the doc
strings by typing '?' followed by the name of the function in the Julia
prompt, but not with help(funcname).

Thank you all,
-Júlio


[julia-users] Re: Organizing code around Jump models

2015-06-03 Thread Miles Lubin
Hi Francois,

Could you give an example of how you might organize this code in a more 
namespace heavy language like C++ or Java? I think this is quite a general 
question on how to structure large Julia applications, not really specific 
to JuMP.

Best,
Miles

On Wednesday, June 3, 2015 at 9:07:03 PM UTC+2, Francois Gilbert wrote:
>
> Hi all,
>
> Is  anyone aware of any effort building large OR applications?  I am 
> currently working at organizing a relatively large code base making use of 
> the JuMP libraries.  The  context is unit-commitment and transmission 
> planning.  Flexibility and code re-use is among our priorities. 
>
> Here are some of the design choices we made so far:
>
> 1) JuMP models are encapsulated in types that hold: 
> a) references to the variable names, constraints (when multipliers are 
> needed) and indices.  These are otherwise difficult to extract directly 
> from the JuMP object
> b) data structure that are required for model specification (generator 
> characteristics, transmission lines, etc) 
> c) exogenous variable values (demand scenarios, initial conditions, etc)
>
> 2) Most models we use are derived from a basic unit commitment model. The 
> derivation is implemented using 
> composition: the derived type manages a reference to the base type, and 
> provides a number of proxies to some of the base type data structure. 
>
> 3) The objective and constraints  are specified  through function calls, 
> using polymorphism on the basis of an underlying abstract types hierarchy. 
>
> I also toyed for a while with submodules to incorporate functionality that 
> only make sense within the scope of a given base module. But from the 
> language point of view, I did not see much benefit in doing so. That is,  a 
> Julia submodule does not see anything of the base module, unless it is 
> explicitly use/imported, and is thus in the same position as any other 
> module defined outside the scope of the base module.  Are there any Julia 
> packages making use submodules? 
>
> Any suggestions/comments are very welcome,
>
> François
>
>

[julia-users] Error installing GnuTLS

2015-06-03 Thread Samuel Colvin
Just tried to install Quandl and found GnuTLS won't install, I'm on Ubuntu 
15.04, 

version info:
Julia Version 0.3.8
Commit 79599ad (2015-04-30 23:40 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: liblapack.so.3
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

Error:

INFO: Cloning cache of GnuTLS from git://github.com/JuliaWeb/GnuTLS.jl.git
INFO: Installing GnuTLS v0.0.4
INFO: Building Nettle
INFO: Building GnuTLS
INFO: Attempting to Create directory 
/home/samuel/.julia/v0.3/GnuTLS/deps/downloads
INFO: Downloading file 
http://www.lysator.liu.se/~nisse/archive/nettle-2.7.tar.gz
  % Total% Received % Xferd  Average Speed   TimeTime Time 
 Current
 Dload  Upload   Total   SpentLeft 
 Speed
100 1521k  100 1521k0 0   814k  0  0:00:01  0:00:01 --:--:-- 
 814k
INFO: Done downloading file 
http://www.lysator.liu.se/~nisse/archive/nettle-2.7.tar.gz
INFO: Attempting to Create directory 
/home/samuel/.julia/v0.3/GnuTLS/deps/src
INFO: Attempting to Create directory /home/samuel/.julia/v0.3/GnuTLS/deps
INFO: Directory /home/samuel/.julia/v0.3/GnuTLS/deps already created
INFO: Attempting to Create directory 
/home/samuel/.julia/v0.3/GnuTLS/deps/src/nettle-2.7
INFO: Attempting to Create directory 
/home/samuel/.julia/v0.3/GnuTLS/deps/builds/nettle
INFO: Changing Directory to 
/home/samuel/.julia/v0.3/GnuTLS/deps/builds/nettle
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for -R flag... using -Wl,-rpath,
Searching for libraries
checking /home/samuel/.julia/v0.3/GnuTLS/deps/usr/lib... not found
checking /usr/local/lib... added
checking /sw/local/lib... not found
checking /sw/lib... not found
checking /usr/gnu/lib... not found
checking /opt/gnu/lib... not found
checking /sw/gnu/lib... not found
checking /usr/freeware/lib... not found
checking /usr/pkg/lib... not found
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/samuel/.julia/v0.3/GnuTLS/deps/builds/nettle':
configure: error: C compiler cannot create executables


There then follows a long error from the line which failed (the exit code 
is 77), but it looks to me like the all the "not found" and the "checking 
whether the C compiler works... no" are the real error here. I have gcc, 
build-essential and all the versions of llvm from the aptitude installed. 
Nettle installed fine before this.

I assume I'm doing/not doing/missing something very dumb?

Is the problem that I need to somehow install llvm-3.3?


Re: [julia-users] LinSpace - why is the len field floating point?

2015-06-03 Thread Stefan Karpinski
I originally had the length field as an Int, but then you can't make
*really* long LinSpace objects, which is part of why having this being an
object rather than a materialized array is useful anyway. Then I considered
having the length type as a second type parameter, but that's really
annoying. Finally, I realized that since you have to convert the length to
the floating-point type anyway, why not just store it as that type? That's
one less conversion to do on each element computation anyway. So this way
you can, for example, do this:

julia> s = linspace(big(0),big(1),big(2)^100-1)
linspace(0.00e+00,1.00,1267650600228229401496703205375)

julia> typeof(s)
LinSpace{Base.MPFR.BigFloat}

julia> length(s)
1267650600228229401496703205375

julia> s[end>>>1]
4.92111390947789881945882714347159691672712213365495e-01

julia> s[end>>>1+1]
5.00e-01

julia> s[end>>>1+2]
5.07888609052210118054117285652840308327287786634505e-01



On Fri, May 29, 2015 at 11:24 AM, Patrick Kofod Mogensen <
patrick.mogen...@gmail.com> wrote:

> In the definition of the immutable LinSpace, we have start, stop, len, and
> divisor. They are all floating point typed. Why is that? I mean, len is
> supposed to be the number of elements, why wouldn't that be an integer?
>
> - Patrick
>


[julia-users] Re: Constructing a block diagonal matrix from an array of square matrices

2015-06-03 Thread Patrick O'Leary
For sparse arrays, you can use `blkdiag()`.

For v0.3, the method David posted is probably the best approach.

Starting in v0.4, you can call `cat([1,2], matrices...)` where the 
`matrices` variable is your array of arrays. Note that the splat is 
undesirable if this container is quite large.

On Wednesday, June 3, 2015 at 12:07:19 PM UTC-5, Marc Gallant wrote:
>
> If I have an array of square matrices of different sizes; e.g.,
>
> 3-element Array{Array{Float64,2},1}:
>  2x2 Array{Float64,2}:
>  0.539932  0.429322
>  0.623487  0.0397795
>  2x2 Array{Float64,2}:
>  0.35508   0.700551
>  0.768214  0.954056
>  3x3 Array{Float64,2}:
>  0.953354  0.453831   0.991583
>  0.159975  0.116518   0.355275
>  0.791447  0.0104295  0.151609
>
>
> Where the number of elements may be much larger than 3 (e.g., 1000), how 
> do I construct a block diagonal matrix, where the blocks are the matrices 
> in the array? For the array above, this would be
>
> 7x7 Array{Float64,2}:
>  0.539932  0.429322   0.0   0.0   0.0   0.00.0
>  0.623487  0.0397795  0.0   0.0   0.0   0.00.0
>  0.0   0.00.35508   0.700551  0.0   0.00.0
>  0.0   0.00.768214  0.954056  0.0   0.00.0
>  0.0   0.00.0   0.0   0.953354  0.453831   0.991583
>  0.0   0.00.0   0.0   0.159975  0.116518   0.355275
>  0.0   0.00.0   0.0   0.791447  0.0104295  0.151609
>
>

[julia-users] Re: Constructing a block diagonal matrix from an array of square matrices

2015-06-03 Thread David P. Sanders


El miércoles, 3 de junio de 2015, 19:07:19 (UTC+2), Marc Gallant escribió:
>
> If I have an array of square matrices of different sizes; e.g.,
>
> 3-element Array{Array{Float64,2},1}:
>  2x2 Array{Float64,2}:
>  0.539932  0.429322
>  0.623487  0.0397795
>  2x2 Array{Float64,2}:
>  0.35508   0.700551
>  0.768214  0.954056
>  3x3 Array{Float64,2}:
>  0.953354  0.453831   0.991583
>  0.159975  0.116518   0.355275
>  0.791447  0.0104295  0.151609
>
>
> Where the number of elements may be much larger than 3 (e.g., 1000), how 
> do I construct a block diagonal matrix, where the blocks are the matrices 
> in the array? For the array above, this would be
>
> 7x7 Array{Float64,2}:
>  0.539932  0.429322   0.0   0.0   0.0   0.00.0
>  0.623487  0.0397795  0.0   0.0   0.0   0.00.0
>  0.0   0.00.35508   0.700551  0.0   0.00.0
>  0.0   0.00.768214  0.954056  0.0   0.00.0
>  0.0   0.00.0   0.0   0.953354  0.453831   0.991583
>  0.0   0.00.0   0.0   0.159975  0.116518   0.355275
>  0.0   0.00.0   0.0   0.791447  0.0104295  0.151609
>
>

One way would be to create a matrix of zeros and just insert the non-zero 
elements in the correct places, e.g.
julia> A = [ 0.539932  0.429322;
0.623487  0.0397795]

julia> M = zeros(4,4)
4x4 Array{Float64,2}:
 0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0

julia> M[1:2, 1:2] = A
2x2 Array{Float64,2}:
 0.539932  0.429322 
 0.623487  0.0397795

julia> M[3:4, 3:4] = A^2
2x2 Array{Float64,2}:
 0.559203  0.248883
 0.361443  0.269259

julia> M
4x4 Array{Float64,2}:
 0.539932  0.429322   0.0   0.0 
 0.623487  0.0397795  0.0   0.0 
 0.0   0.00.559203  0.248883
 0.0   0.00.361443  0.269259

It would not be too hard to write a routine to take in the vector of 
matrices and keep track automatically
of where they should be inserted.


Re: [julia-users] Pause and continue iterators

2015-06-03 Thread Stefan Karpinski
You could use a task, but the performance would be much less good than 
explicitly manipulating the iteration state for many things.


> On Jun 2, 2015, at 6:45 PM, Yichao Yu  wrote:
> 
> I'm wondering what is the best way to do the equivalant with the
> following in python.
> 
> ```
> In [1]: a = range(20)
> 
> In [2]: it = iter(a)
> 
> In [3]: for i in it:
>   if i == 10:
>   break
>  ...:
> 
> In [4]: for i in it:
>  ...: print(i)
>  ...:
> 11
> 12
> 13
> 14
> 15
> 16
> 17
> 18
> 19
> ```
> 
> I know that I can call `start`, `next` and `done` manually but it
> would be nice if I can avoid that.
> 
> I could also wrap the returned value of next in a type but I don't
> know how to make it both generic and fast, e.g. I want the typeinf to
> infer the type as easy as if I call the `start` methods manually
> and I don't want to rely on `next` being type stable (and AFAICT, the
> `next` for Any array is not).
> 
> 
> The exact format doesn't have to be the same with the python version
> but I do want to use `for` loop instead of `while`.


[julia-users] Organizing code around Jump models

2015-06-03 Thread Francois Gilbert
Hi all,

Is  anyone aware of any effort building large OR applications?  I am 
currently working at organizing a relatively large code base making use of 
the JuMP libraries.  The  context is unit-commitment and transmission 
planning.  Flexibility and code re-use is among our priorities. 

Here are some of the design choices we made so far:

1) JuMP models are encapsulated in types that hold: 
a) references to the variable names, constraints (when multipliers are 
needed) and indices.  These are otherwise difficult to extract directly 
from the JuMP object
b) data structure that are required for model specification (generator 
characteristics, transmission lines, etc) 
c) exogenous variable values (demand scenarios, initial conditions, etc)

2) Most models we use are derived from a basic unit commitment model. The 
derivation is implemented using 
composition: the derived type manages a reference to the base type, and 
provides a number of proxies to some of the base type data structure. 

3) The objective and constraints  are specified  through function calls, 
using polymorphism on the basis of an underlying abstract types hierarchy. 

I also toyed for a while with submodules to incorporate functionality that 
only make sense within the scope of a given base module. But from the 
language point of view, I did not see much benefit in doing so. That is,  a 
Julia submodule does not see anything of the base module, unless it is 
explicitly use/imported, and is thus in the same position as any other 
module defined outside the scope of the base module.  Are there any Julia 
packages making use submodules? 

Any suggestions/comments are very welcome,

François



Re: [julia-users] Get access to PyObject representing python module when using @pyimport macro?

2015-06-03 Thread Jack Minardi
Thanks Isaiah, the workaround does the job for now.

On Tue, Jun 2, 2015 at 10:05 PM, Isaiah Norton 
wrote:

> @pyimport ends up creating a closure (`pymember`) around the PyObject
> handle (passed as 'o') for the module, here:
>
>
> https://github.com/stevengj/PyCall.jl/blob/0823f7c08ae1fd8a82cd3fb8fa5ecb5623087864/src/PyCall.jl#L311-L328
>
> I don't immediately see a way to get a reference to 'o' back out (it might
> be useful to save a reference, and would be pretty simple to add that to
> PyCall). However, there is a work-around -- do what you would do to find a
> module reference by name in Python:
>
> julia> using PyCall
> julia> @pyimport sys
> julia> m = sys.modules["math"]
> PyObject 
> julia> m[:foo] = 1
>
>
> On Tue, Jun 2, 2015 at 6:56 PM, Jack Minardi  wrote:
>
>> I need to set a module level variable in a python module through PyCall.
>> If I use the `pyimport()` function I can successfully set the module
>> variable on the returned PyObject. Can I get access to this PyObject when
>> using the `@pyimport` macro instead?
>>
>
>


-- 
Jack Minardi
jack.minardi.org
j...@minardi.org


[julia-users] Re: ANN: new package Polyglot (php/perl/python/nodejs interop.)

2015-06-03 Thread Yuri D'Elia
On 06/03/2015 07:02 PM, J Luis wrote:
> An idea. Could Polyglot (Jolyglot would be even nicer) be made to talk with 
> QML? We would than have a bridge with Qt, no?

QML AFAIK has no way to do I/O besides console.log(). Everything else
seems to be already in there, but you would need a small c++ helper to
perform I/O.

If anybody is interested, I could provide some help implementing it. For
my projects I'm still using qt4 (when I tried qt5 the performance hit
was too big).




[julia-users] Constructing a block diagonal matrix from an array of square matrices

2015-06-03 Thread Marc Gallant
If I have an array of square matrices of different sizes; e.g.,

3-element Array{Array{Float64,2},1}:
 2x2 Array{Float64,2}:
 0.539932  0.429322
 0.623487  0.0397795
 2x2 Array{Float64,2}:
 0.35508   0.700551
 0.768214  0.954056
 3x3 Array{Float64,2}:
 0.953354  0.453831   0.991583
 0.159975  0.116518   0.355275
 0.791447  0.0104295  0.151609


Where the number of elements may be much larger than 3 (e.g., 1000), how do 
I construct a block diagonal matrix, where the blocks are the matrices in 
the array? For the array above, this would be

7x7 Array{Float64,2}:
 0.539932  0.429322   0.0   0.0   0.0   0.00.0
 0.623487  0.0397795  0.0   0.0   0.0   0.00.0
 0.0   0.00.35508   0.700551  0.0   0.00.0
 0.0   0.00.768214  0.954056  0.0   0.00.0
 0.0   0.00.0   0.0   0.953354  0.453831   0.991583
 0.0   0.00.0   0.0   0.159975  0.116518   0.355275
 0.0   0.00.0   0.0   0.791447  0.0104295  0.151609



[julia-users] Re: ANN: new package Polyglot (php/perl/python/nodejs interop.)

2015-06-03 Thread J Luis
An idea. Could Polyglot (Jolyglot would be even nicer) be made to talk with 
QML? We would than have a bridge with Qt, no?


quarta-feira, 3 de Junho de 2015 às 09:11:16 UTC+1, Yuri D'Elia escreveu:
>
> Hi everyone, 
>
> I'm announcing the availability of a new package for cross-language 
> interoperability called "Polyglot", already available as a registered 
> package: https://github.com/wavexx/Polyglot.jl 
>
> Polyglot allows to call a remote function in a supported language with 
> automatic serialization of basic types. It also allows to export local 
> Julia functions to the remote system with the same method (that is, the 
> remote system can call back Julia with regular functions). Local/remote 
> functions can also call each-other recursively without any limitation. 
>
> For a brief example, please see: 
>
> http://www.thregr.org/~wavexx/software/Polyglot.jl#overview 
>
> The currently supported languages are PHP, Perl, Python (2/3/PyPy) and 
> JavaScript (Node.js). A Common Lisp (sbcl/clisp) and Julia backends are 
> also in the works. 
>
> I'm actively looking for feedback, especially about the interface of the 
> module. I'd love to introduce some uniformity and reuse generic method 
> names if possible. Please keep that in mind: the package is stable, but 
> I'll shuffle things around in the beginning if needed. 
>
> For those interested, "Polyglot" spawns long-lived coprocesses which 
> communicate through a simple serial protocol. While not being as 
> efficient as a dl-opened interpreter, this method allows to have 
> multiple interpreters running at the same time, with different versions 
> and potentially running on different systems. When the Julia backend 
> will be ready, Polyglot will have many similarities to current's Julia 
> parallel/multiprocessing interface in both API and design. 
>
> Polyglot is almost a direct port of the Python "Bond" package 
> (https://pypi.python.org/pypi/python-bond). In fact, it shares the same 
> driver infrastructure and I currently recommend to read through it's 
> practical examples and language support section (at least until I finish 
> writing the remaining documentation). 
>
> Please share your ideas! 
>
>

Re: [julia-users] Help to ccall

2015-06-03 Thread Daniel Høegh
Awesome thank you so much, I had missed that the last argument should be a 
pointer to the length and not the length. The working version is:

function my_replace(s::AbstractString, pat::Regex, rep_in)
offset=0
Base.compile(pat)
subject = bytestring(s)
rep = bytestring(rep_in)
buffer = Array(UInt8, 256*2)
re = pat.regex
length = Ref{Csize_t}(sizeof(buffer))
rc = ccall((:pcre2_substitute_8, Base.PCRE.PCRE_LIB), Cint,
   (Ptr{Void}, Ptr{UInt8}, Csize_t, Csize_t, Cuint, Ptr{Void}, 
Ptr{Void}, Ptr{UInt8}, Csize_t, Ptr{UInt8}, Ref{Csize_t}),
re, subject, sizeof(subject), offset, pat.match_options, 
pat.match_data,
Base.PCRE.MATCH_CONTEXT, rep, sizeof(rep), buffer, length)
println(rc)
bytestring(pointer(buffer))
end
my_replace("adsa10as", r"a(\d+)", " \$1 ")

I will probably make a pull to add this functionality to base, if i can get it 
wrapped up nicely.

Re: [julia-users] Help to ccall

2015-06-03 Thread Isaiah Norton
Real quick look: pasting that in gdb on linux says at least the last
parameter is wrong -- it is expecting a pointer there (to store the bytes
written?)

On Wed, Jun 3, 2015 at 4:51 AM, Daniel Høegh  wrote:

> Hi I hope someone could help me to understand why my code errors. I am
> trying to wrap this http://pcre.org/current/doc/html/pcre2_substitute.html
> function from the pcre2 library. I am working on latest master as it comes
> with pcre2. My wrap look like:
>
> function my_replace(s::AbstractString, pat::Regex, rep_in)
> offset=0
> subject = bytestring(s)
> rep = bytestring(rep_in)
> buffer = Array(UInt8, 256)
> re = pat.regex
> rc = ccall((:pcre2_substitute_8, Base.PCRE.PCRE_LIB), Cint,
>(Ptr{Void}, Ptr{UInt8}, Csize_t, Csize_t, Cuint, Ptr{Void},
> Ptr{Void}, Ptr{UInt8}, Csize_t, Ptr{UInt8}, Csize_t),
> re, subject, sizeof(subject), offset, pat.match_options,
> pat.match_data,
> Base.PCRE.MATCH_CONTEXT, rep, sizeof(rep), buffer,
> sizeof(buffer))
>
> bytestring(pointer(buffer))
> end
>
> julia> my_replace("ads10as", r"a(\d+)", "\$1")
>
> Please submit a bug report with steps to reproduce this fault, and any
> error messages that follow (in their entirety). Tha
> Exception: EXCEPTION_ACCESS_VIOLATION at 0x65811787 -- pcre2_substitute_8
> at  (unknown line)
> pcre2_substitute_8 at
> C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libpcre2-8.DLL (unknown line)
> my_replace at none:7
> jl_apply_generic at C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll
> (unknown line)
> jl_interpret_toplevel_expr at
> C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll (unknown line)
> jl_interpret_toplevel_thunk_with at
> C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll (unknown line)
> jl_eval_with_compiler_p at
> C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll (unknown line)
> jl_toplevel_eval_in at
> C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll (unknown line)
> eval_user_input at REPL.jl:62
> jlcall_eval_user_input_1356 at  (unknown line)
> jl_apply_generic at C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll
> (unknown line)
> anonymous at task.jl:91
> jl_unprotect_stack at
> C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll (unknown line)
>


Re: [julia-users] Re: Easy way to find only unary methods of an operator?

2015-06-03 Thread Jiahao Chen
>
> The unary & is a special syntax, not a generic operator, that you can only
> use in ccall expressions.


Actually, there is a fallback no-op method

(&)(x::Integer) = x

defined for "bitwise and" with one argument, which Scott's example invokes.

Thanks,

Jiahao Chen
Research Scientist
MIT CSAIL


Re: [julia-users] Equivalent to MATLAB/Octave accumarray()

2015-06-03 Thread Júlio Hoffimann
Totally agree Tim, thank you for sharing your thoughts on that.

-Júlio


Re: [julia-users] ANN: new package Polyglot (php/perl/python/nodejs interop.)

2015-06-03 Thread Tim Holy
This looks really amazing. Thanks for contributing it!

Best,
--Tim

On Wednesday, June 03, 2015 10:10:45 AM Yuri D'Elia wrote:
> Hi everyone,
> 
> I'm announcing the availability of a new package for cross-language
> interoperability called "Polyglot", already available as a registered
> package: https://github.com/wavexx/Polyglot.jl
> 
> Polyglot allows to call a remote function in a supported language with
> automatic serialization of basic types. It also allows to export local
> Julia functions to the remote system with the same method (that is, the
> remote system can call back Julia with regular functions). Local/remote
> functions can also call each-other recursively without any limitation.
> 
> For a brief example, please see:
> 
> http://www.thregr.org/~wavexx/software/Polyglot.jl#overview
> 
> The currently supported languages are PHP, Perl, Python (2/3/PyPy) and
> JavaScript (Node.js). A Common Lisp (sbcl/clisp) and Julia backends are
> also in the works.
> 
> I'm actively looking for feedback, especially about the interface of the
> module. I'd love to introduce some uniformity and reuse generic method
> names if possible. Please keep that in mind: the package is stable, but
> I'll shuffle things around in the beginning if needed.
> 
> For those interested, "Polyglot" spawns long-lived coprocesses which
> communicate through a simple serial protocol. While not being as
> efficient as a dl-opened interpreter, this method allows to have
> multiple interpreters running at the same time, with different versions
> and potentially running on different systems. When the Julia backend
> will be ready, Polyglot will have many similarities to current's Julia
> parallel/multiprocessing interface in both API and design.
> 
> Polyglot is almost a direct port of the Python "Bond" package
> (https://pypi.python.org/pypi/python-bond). In fact, it shares the same
> driver infrastructure and I currently recommend to read through it's
> practical examples and language support section (at least until I finish
> writing the remaining documentation).
> 
> Please share your ideas!



Re: [julia-users] Equivalent to MATLAB/Octave accumarray()

2015-06-03 Thread Tim Holy
On Wednesday, June 03, 2015 06:20:17 AM Júlio Hoffimann wrote:
> Thank you Isaiah, is there a reason to not add it to Base?

I suppose we could add it, but rather than write a clone of Matlab's 6-
argument function (hmm, I want a sparse matrix output, is `issparse` the 5th 
or 6th argument to `accumarray`?), the flexibility of writing your own loops is 
pretty hard to beat. I mean, the basic return-an-array version

function accumarray(subs, val, sz=(maximum(subs),))
A = zeros(eltype(val), sz...)
for i = 1:length(val)
A[subs[i]] += val[i]
end
A
end

is dirt simple, and probably about as fast to write as it is to look up the 
documentation for Matlab's version.

Other problems:
- having an `issparse` input makes the result not be type-stable (though there 
are ways around this)
- a Dict output will almost always be preferable to a sparse-matrix output, if 
that's what you want, and is scarcely any more lines of code
- why would you even want to construct the inputs, subs and val, explicitly? 
Why not just do it on-the-fly in the middle of your computation? That will 
always be faster, more memory efficient, etc.

In the end, the only reason you need something like accumarray in Matlab is 
because you can't write fast loops. In Julia, you can. That doesn't mean we 
can't have accumarray, but if it's added it should be given a decent interface 
(and therefore be different from the Matlab version).

--Tim



Re: [julia-users] Equivalent to MATLAB/Octave accumarray()

2015-06-03 Thread Júlio Hoffimann
Thank you Isaiah, is there a reason to not add it to Base?

-Júlio


Re: [julia-users] Using Atlassian Stash with Julia

2015-06-03 Thread Isaiah Norton
Atlassian's Bitbucket uses pygments, which has Julia support. If Stash also
uses pygments then they might just need to enable Julia support.

https://bitbucket.org/site/master/issue/4958/upgrade-pygments-so-we-get-julia-syntax

On Wed, Jun 3, 2015 at 7:50 AM, Scott Jones 
wrote:

> We are currently testing using Atassian's Stash product, and it seems like
> it doesn't have Julia support for the ``` ... code ... ``` sections.
> Does anybody here have experience with Stash, and with setting it up so
> that it works well with Julia?
> Currently, we have GitLab, and of course, GitHub (but Enterprise, on our
> own servers) could be an (expensive) option as well.
>
> Thanks,
> Scott
>


Re: [julia-users] Equivalent to MATLAB/Octave accumarray()

2015-06-03 Thread Isaiah Norton
Try this code?
https://groups.google.com/d/msg/julia-users/QNlwE2wsZrU/FCerayBUMZ0J

On Wed, Jun 3, 2015 at 1:06 AM, Júlio Hoffimann 
wrote:

> Hi,
>
> Is there any equivalent to accumarray() in Julia?
> http://www.mathworks.com/help/matlab/ref/accumarray.html
>
> -Júlio
>


[julia-users] Gilbert–Johnson–Keerthi distance algorithm

2015-06-03 Thread Tony Kelman
Just curious, has anyone implemented the Gilbert–Johnson–Keerthi algorithm 

 for 
collision detection in Julia? If not I'll implement the pseudocode and 
start from there, but just wanted to put the question out there in case 
there's some nicer code somewhere that has already had time put into it 
which would give me a jump-start.

Thanks,
Tony


[julia-users] Using Atlassian Stash with Julia

2015-06-03 Thread Scott Jones
We are currently testing using Atassian's Stash product, and it seems like 
it doesn't have Julia support for the ``` ... code ... ``` sections.
Does anybody here have experience with Stash, and with setting it up so 
that it works well with Julia?
Currently, we have GitLab, and of course, GitHub (but Enterprise, on our 
own servers) could be an (expensive) option as well.

Thanks,
Scott


[julia-users] Re: Interop with C on an array of mutable structs

2015-06-03 Thread Scott Jones
What state do you feel it is in currently (after all the 0.4 breaking 
changes that have happened)?   Have you thought about using Steven 
Johnson's DecFP.jl package to handle decimal floating point types?
This would be great...

On Tuesday, June 2, 2015 at 5:09:51 PM UTC+2, John Myles White wrote:
>
> I've been fixing up the MySQL.jl package recently. To receive data on the 
> client-side from prepared statements, I need to pass around an array of 
> mutable structs, defined in MySQL C's API, so that C can populate those 
> structs with data from the server.
>
> If helpful, an example of how this works in pure C is at: 
> http://www.erickcantwell.com/2011/08/mysql-prepared-statements-in-c/
>
> I'm not sure how one is supposed to work with arrays of mutable structs. 
> Since the structs satisfy the isbits() requirement when written as Julia 
> immutables, I think I can get away with passing an array of Julia immutable 
> objects and letting C do all the mutation. Is that the best way to do this 
> sort of thing in Julia?
>
>  -- John
>
>

[julia-users] Help to ccall

2015-06-03 Thread Daniel Høegh
Hi I hope someone could help me to understand why my code errors. I am trying 
to wrap this http://pcre.org/current/doc/html/pcre2_substitute.html function 
from the pcre2 library. I am working on latest master as it comes with pcre2. 
My wrap look like:

function my_replace(s::AbstractString, pat::Regex, rep_in)
offset=0
subject = bytestring(s)
rep = bytestring(rep_in)
buffer = Array(UInt8, 256)
re = pat.regex
rc = ccall((:pcre2_substitute_8, Base.PCRE.PCRE_LIB), Cint,
   (Ptr{Void}, Ptr{UInt8}, Csize_t, Csize_t, Cuint, Ptr{Void}, 
Ptr{Void}, Ptr{UInt8}, Csize_t, Ptr{UInt8}, Csize_t),
re, subject, sizeof(subject), offset, pat.match_options, 
pat.match_data,
Base.PCRE.MATCH_CONTEXT, rep, sizeof(rep), buffer, 
sizeof(buffer))

bytestring(pointer(buffer))
end

julia> my_replace("ads10as", r"a(\d+)", "\$1")

Please submit a bug report with steps to reproduce this fault, and any error 
messages that follow (in their entirety). Tha
Exception: EXCEPTION_ACCESS_VIOLATION at 0x65811787 -- pcre2_substitute_8 at  
(unknown line)
pcre2_substitute_8 at C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libpcre2-8.DLL 
(unknown line)
my_replace at none:7
jl_apply_generic at C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll 
(unknown line)
jl_interpret_toplevel_expr at 
C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll (unknown line)
jl_interpret_toplevel_thunk_with at 
C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll (unknown line)
jl_eval_with_compiler_p at 
C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll (unknown line)
jl_toplevel_eval_in at C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll 
(unknown line)
eval_user_input at REPL.jl:62
jlcall_eval_user_input_1356 at  (unknown line)
jl_apply_generic at C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll 
(unknown line)
anonymous at task.jl:91
jl_unprotect_stack at C:\Users\Hoegh\Julia-0.4.0-dev-03-06\bin\libjulia.dll 
(unknown line)


[julia-users] Re: form -X:X where X is Uint64

2015-06-03 Thread Avik Sengupta
Negating an unsigned effectively causes it to overflow.. it flips all bits 
(rather than the sign bit... which doesnt exist)

*julia> **bits(x)*

*"0100"*

*julia> **bits(-x)*

*"1100"*


So the start of the range you create is greater than typemax(Int64). 

*julia> **-x:x*

*0xfffc:0xfffb*

If you need negation, you need a signed integer, I think. 


Regards

-

Avik


On Wednesday, 3 June 2015 06:12:19 UTC+1, Pete Williams wrote:

> Hi, I'm not sure what the right way to form the range -X:X is when X is 
> Uint64.  It works as expected for smaller Uints
>
> *julia> **Q = uint(4)*
>
> *0x0004*
>
>
> *julia> **M = 0x4*
>
> *0x04*
>
>
> *julia> **typeof(Q)*
>
> *Uint64*
>
>
> *julia> **typeof(M)*
>
> *Uint8*
>
>
> *julia> **[-1*M:M]*
>
> *9-element Array{Int64,1}:*
>
> * -4*
>
> * -3*
>
> * -2*
>
> * -1*
>
> *  0*
>
> *  1*
>
> *  2*
>
> *  3*
>
> *  4*
>
>
> *julia> **[-1*Q:Q]*
>
> *ERROR: OverflowError()*
>
> * in vcat at range.jl:500*
>
> obviously I can make an Int64 copy of the Uint64 to fix this, but I'd like 
> to know if there is a more graceful way to do this.  Thanks.
>


[julia-users] ANN: new package Polyglot (php/perl/python/nodejs interop.)

2015-06-03 Thread Yuri D'Elia
Hi everyone,

I'm announcing the availability of a new package for cross-language
interoperability called "Polyglot", already available as a registered
package: https://github.com/wavexx/Polyglot.jl

Polyglot allows to call a remote function in a supported language with
automatic serialization of basic types. It also allows to export local
Julia functions to the remote system with the same method (that is, the
remote system can call back Julia with regular functions). Local/remote
functions can also call each-other recursively without any limitation.

For a brief example, please see:

http://www.thregr.org/~wavexx/software/Polyglot.jl#overview

The currently supported languages are PHP, Perl, Python (2/3/PyPy) and
JavaScript (Node.js). A Common Lisp (sbcl/clisp) and Julia backends are
also in the works.

I'm actively looking for feedback, especially about the interface of the
module. I'd love to introduce some uniformity and reuse generic method
names if possible. Please keep that in mind: the package is stable, but
I'll shuffle things around in the beginning if needed.

For those interested, "Polyglot" spawns long-lived coprocesses which
communicate through a simple serial protocol. While not being as
efficient as a dl-opened interpreter, this method allows to have
multiple interpreters running at the same time, with different versions
and potentially running on different systems. When the Julia backend
will be ready, Polyglot will have many similarities to current's Julia
parallel/multiprocessing interface in both API and design.

Polyglot is almost a direct port of the Python "Bond" package
(https://pypi.python.org/pypi/python-bond). In fact, it shares the same
driver infrastructure and I currently recommend to read through it's
practical examples and language support section (at least until I finish
writing the remaining documentation).

Please share your ideas!



Re: [julia-users] IJulia: Swap shift-enter for enter?

2015-06-03 Thread Jacob Quinn
If you go into the "IJulia" package in your Sublime packages directory
(there's a menu item to "Browse Packages", you'll fine keymapping files for
each platform. Just find the one that says "shift+enter" and change it to
"enter" and save. Done.

-Jacob


On Wed, Jun 3, 2015 at 12:56 AM, RecentConvert  wrote:

> Is it possible to swap shift-enter for enter in IJulia?
>
> At the moment I use Sublime for my Julia coding but despite using it for
> months now I find shift-enter to execute to be a royal pain. No other
> program I use does this. I don't mind it in my scripts but in the command
> line I find it annoying.
>
> Given that it comes from the usage case of iPython notebooks it makes
> sense for them to have shift-enter to execute. I generally like the
> functionality of Sublime and haven't had time to find a suitable
> replacement, if there is one, which doesn't require shift-enter.
>