Re: [julia-users] equivalent of issymmetric(A) in julia

2016-09-07 Thread Ahmed Mazari
thanks


On Wed, Sep 7, 2016 at 2:55 PM, Yichao Yu  wrote:

>
>
> On Wed, Sep 7, 2016 at 8:48 AM, Ahmed Mazari 
> wrote:
>
>> Hello,
>> l want to check whether my matrix is symmetric. in matlab we have the
>> fucntion issymmetric(A) , do we have any function in matlab that does
>> the same ?
>>
>
> I don't know what exactly the matlab function does but we have
> `issymmetic` that checks if the matrix is symmetric. It's called issym on
> 0.4 I believe.
>
>
>>
>> thanks
>>
>
>


[julia-users] equivalent of issymmetric(A) in julia

2016-09-07 Thread Ahmed Mazari
Hello,
l want to check whether my matrix is symmetric. in matlab we have the 
fucntion issymmetric(A) , do we have any function in matlab that does the 
same ?

thanks


Re: [julia-users] Re: How to shuffle the order of matrix by rows

2016-09-07 Thread Ahmed Mazari
thank you

On Wed, Sep 7, 2016 at 12:03 PM, Mosè Giordano 
wrote:

> Hi Ahmed,
>
>
> Hello,
>> l have a matrix as follow :
>>  k=rand(1:100,3,3)
>> 3x3 Array{Int64,2}:
>>  97  26  77
>>  58  64  86
>>  87  85  99
>>
>>
>> l want to shuffle randomly the order by lines for instance line 1 becomes
>> 3. l have a matrix of 1 by 700 .
>>
>
>  The following function is based on the definition of shuffle! in Julia
> 0.4 (it's different in Julia 0.5)
>
> function shufflerows!{T<:Real}(a::AbstractArray{T})
> for i = size(a, 1):-1:2
> j = rand(1:i)
> a[i,:], a[j,:] = a[j,:], a[i,:]
> end
> return a
> end
>
> Here is it in action:
>
> julia> a = rand(1:100, 5, 3)
> 5x3 Array{Int64,2}:
>  18  90  34
>   9  24  61
>  49  73  84
>  70  85  20
>  66  59  37
>
> julia> shufflerows!(a)
> 5x3 Array{Int64,2}:
>   9  24  61
>  18  90  34
>  70  85  20
>  49  73  84
>  66  59  37
>
> Note that the matrix is changed in-place.
>
> Cheers,
> Mosè
>


[julia-users] How to shuffle the order of matrix by rows

2016-09-07 Thread Ahmed Mazari
Hello,
l have a matrix as follow :
 k=rand(1:100,3,3)
3x3 Array{Int64,2}:
 97  26  77
 58  64  86
 87  85  99


l want to shuffle randomly the order by lines for instance line 1 becomes 
3. l have a matrix of 1 by 700 .

thank you


Re: [julia-users] How to avoid LOAD_PATH at each julia session

2016-09-06 Thread Ahmed Mazari
thank you

On Tuesday, September 6, 2016 at 4:06:21 PM UTC+2, Michele Zaffalon wrote:
>
> And here: 
> http://docs.julialang.org/en/release-0.4/manual/modules/?highlight=juliarc
>
> On Tue, Sep 6, 2016 at 4:05 PM, Michele Zaffalon  > wrote:
>
>> Put that line in .juliarc as described in the docs: 
>> http://docs.julialang.org/en/release-0.4/manual/getting-started/?highlight=juliarc
>>
>> On Tue, Sep 6, 2016 at 4:00 PM, Ahmed Mazari > > wrote:
>>
>>> hello
>>> push!(LOAD_PATH," the path")
>>>
>>> how can l avoid putting this line of code at each julia session. each 
>>> time l went to julia l should do that and it's really boring
>>>
>>> thank you
>>>
>>
>>
>

[julia-users] How to concatenate matrices by row

2016-09-06 Thread Ahmed Mazari
Hello,
l have 10 matrices of 5000 by 700. Each matrix is stored in a file , so l 
have 10 files.
l want to create a new file that contains all the matrices  (5 by 700) 
that l fill by rows .

thank you


[julia-users] How to avoid LOAD_PATH at each julia session

2016-09-06 Thread Ahmed Mazari
hello
push!(LOAD_PATH," the path")

how can l avoid putting this line of code at each julia session. each time 
l went to julia l should do that and it's really boring

thank you


[julia-users] Re: How to plot different histograms in one histogram ?

2016-09-01 Thread Ahmed Mazari

the link talks about plotting in python . l tried to implement the code but 
the function  dic is not recognized . the error returned is " dic not 
defined"




*common_params = dict(bins=20,  range=(-5, 5), 
 normed="True")*
On Thursday, September 1, 2016 at 2:50:09 PM UTC+2, Steven G. Johnson wrote:
>
>  
> http://stackoverflow.com/questions/9497524/displaying-3-histograms-on-1-axis-in-a-legible-way-matplotlib
>


[julia-users] Re: How to store graphics in julia ? png and pdf

2016-09-01 Thread Ahmed Mazari
so the  structure to save histograms in different png file will be as 
follows :

using PyPlot

for i in 1:1000
h = plt[:hist](x[i],40) # Histogram
*savefig("h$i.png")*
end 

is it like this ? call h at each iteration ! 
h1 . h1000 
On Thursday, September 1, 2016 at 2:48:27 PM UTC+2, Steven G. Johnson wrote:
>
>
>
> On Thursday, September 1, 2016 at 8:22:50 AM UTC-4, Ahmed Mazari wrote:
>>
>> Hello,
>>
>> l want to know how to directly from a code save my histograms in my 
>> repertory.
>>
>>
>> using PyPlot
>>
>> for i in 1:1000
>> h = plt[:hist](x[i],40) # Histogram
>> # how to store each x[i] in a png format in my desktop
>>
>>
> savefig("myfile$i.png")
>
> (exactly as in Matplotlib). 
>


[julia-users] How to plot different histograms in one histogram ?

2016-09-01 Thread Ahmed Mazari
Hello, 
l have different function to plot but l want them in one histogram so that 
to be able to compare.


h1 = plt[:hist](x,40) # Histogram
h2 = plt[:hist](y,40) # Histogram
h2 = plt[:hist](z,40) # Histogram
h4 = plt[:hist](k,40) # Histogram
h5 = plt[:hist](m,40) # Histogram


bins of h1 : red
bins of h2 : green 

and so on 

Is it possible to do that ?

thank you


[julia-users] How to store graphics in julia ? png and pdf

2016-09-01 Thread Ahmed Mazari
Hello,

l want to know how to directly from a code save my histograms in my 
repertory.


using PyPlot

for i in 1:1000
h = plt[:hist](x[i],40) # Histogram
# how to store each x[i] in a png format in my desktop

end


 l want to have in my desktop histograms saved in different png file then 
all the histograms in one pdf file.

x1.png
x2.png
x3.png
x4.png
.
.
.x1000.png


and all the histograms from 1 to 1000 in one pdf file  x.pdf

thank you 


[julia-users] Re: Transforming vector to upper triangular matrix

2016-08-24 Thread Ahmed Mazari
How to transform a lower triangular matrix to a vector ? l used the 
function vec( )  and it doesn't work l got this code error
ERROR: ArgumentError: Triangular matrix must have two dimensions
 in similar at linalg/triangular.jl:27
 in reshape at abstractarray.jl:213
 in vec at abstractarraymath.jl:14




On Thursday, April 25, 2013 at 4:46:43 PM UTC+2, Theodore Papamarkou wrote:
>
> Is there a neat and efficient way to solve the following problem in Julia? 
> Assume a vector that contains n*(n+1)/2 elements. The aim is to pack these 
> elements into the diagonal and upper right triangular portion of an n*n 
> matrix. For example, the vector 1:10 would be transformed to the 4*4 matrix 
>  1  2  3   4
>  0  5  6   7
>  0  0  8   9
>  0  0  0  10
> I am not so familiar with handling of symmetric and triangular matrices in 
> Julia. Is there some built-in support for this?
>


Re: [julia-users] Make a histogram

2016-08-23 Thread Ahmed Mazari
but the x-axis must be ordered from the smallest to the largest value . My 
question know is how to determine the number of bins ?
On Tuesday, August 23, 2016 at 4:46:22 PM UTC+2, Christof Stocker wrote:
>
> If you know the categories then one thing you could do is think about it 
> as a barplot
>
> *julia> **UnicodePlots.barplot(a[:,1], a[:,2], symb = "▇")*
> *  ┌┐* 
> *7 │**▇▇** 4**│* 
> *4 │**▇▇▇** 2*   *│* 
> *9 │**▇▇** 3**│* 
>*10 │**▇▇▇** 1*   *│* 
> *2 │**▇** 5* *│* 
> *3 │**▇▇▇** 1*   *│* 
> *5 │**▇▇▇** 1*   *│* 
> *8 │**▇▇▇** 1*   *│* 
> *6 │**▇▇▇** 1*   *│* 
> *1 │**▇▇▇** 1*   *│* 
> *  └────────┘* 
>
> On 23 Aug 2016, at 16:14, Ahmed Mazari > 
> wrote:
>
> Hello, 
> l have this matrix where the first column represents different values and 
> second column represents the number of occurences of each value. How can 
> plot a histogram x-axis : the different values, y-axis : the number of 
> occurences.
>
> 
> 10x2 Array{Int64,2}:
>   7  4
>   4  2
>   9  3
>  10  1
>   2  5
>   3  1
>   5  1
>   8  1
>   6  1
>   1  1
>
>
>
> Thank you
>
>
>

[julia-users] Make a histogram

2016-08-23 Thread Ahmed Mazari
Hello, 
l have this matrix where the first column represents different values and 
second column represents the number of occurences of each value. How can 
plot a histogram x-axis : the different values, y-axis : the number of 
occurences.


10x2 Array{Int64,2}:
  7  4
  4  2
  9  3
 10  1
  2  5
  3  1
  5  1
  8  1
  6  1
  1  1



Thank you


[julia-users] Re: ERROR: MethodError: `vec2ltri_alt` has no method matching vec2ltri_alt(::Array{Float64,2})

2016-08-22 Thread Ahmed Mazari


function vec2ltri_alt{T}(v::AbstractVector{T}, z::T=zero(T))
n = length(v)
v1 = vcat(0,v)
s = round(Int,(sqrt(8n+1)-1)/2)
s*(s+1)/2 == n || error("vec2utri: length of vector is not triangular")
s+=1
[ i>j ? v1[round(Int, j*(j-1)/2+i)] : (i == j ? z : NaN) for i=1:s, j=1:s ]
end



On Monday, August 22, 2016 at 4:58:56 PM UTC+2, Ahmed Mazari wrote:
>
> Hello,
>
> relying on these two links. l tried to make a lower triangular matrix from 
> a given matrix but it doesn't work.
>
> the used function is 
>
> function vec2ltri_alt{T}(v::AbstractVector{T}, z::T=zero(T)) n = length(v) v1 
> = vcat(0,v) s = round(Int,(sqrt(8n+1)-1)/2) s*(s+1)/2 == n || 
> error("vec2utri: length of vector is not triangular") s+=1 [ i>j ? 
> v1[round(Int, j*(j-1)/2+i)] : (i == j ? z : NaN) for i=1:s, j=1:s ] end
>
>
>
> l got this error  when l did this
>
> vec2ltri_alt(rand(5000,5000)) #  because l have a matrix of 5000 by 5000, 
> so l gave as a paramter my matrix
>
> *ERROR: MethodError: `vec2ltri_alt` has no method matching 
> vec2ltri_alt(::Array{Float64,2})*
>
>
> http://stackoverflow.com/questions/39039553/lower-triangular-matrix-in-julia
>
> https://groups.google.com/forum/#!topic/julia-users/UARlZBCNlng
>
> thank you
>


[julia-users] ERROR: MethodError: `vec2ltri_alt` has no method matching vec2ltri_alt(::Array{Float64,2})

2016-08-22 Thread Ahmed Mazari
Hello,

relying on these two links. l tried to make a lower triangular matrix from 
a given matrix but it doesn't work.

the used function is 

function vec2ltri_alt{T}(v::AbstractVector{T}, z::T=zero(T)) n = length(v) v1 = 
vcat(0,v) s = round(Int,(sqrt(8n+1)-1)/2) s*(s+1)/2 == n || error("vec2utri: 
length of vector is not triangular") s+=1 [ i>j ? v1[round(Int, j*(j-1)/2+i)] : 
(i == j ? z : NaN) for i=1:s, j=1:s ] end



l got this error  when l did this

vec2ltri_alt(rand(5000,5000)) #  because l have a matrix of 5000 by 5000, 
so l gave as a paramter my matrix

*ERROR: MethodError: `vec2ltri_alt` has no method matching 
vec2ltri_alt(::Array{Float64,2})*

http://stackoverflow.com/questions/39039553/lower-triangular-matrix-in-julia

https://groups.google.com/forum/#!topic/julia-users/UARlZBCNlng

thank you


Re: [julia-users] Re: lower triangular matrix in julia

2016-08-19 Thread Ahmed Mazari
4×4 Array{Int64,2}:
 0  1  2  3
 1  0  4  5
 2  4  0  6
 3  5  6  0

a symetric matrix m[i,j] =m[j,i]  and m[i,i]= 0

On Fri, Aug 19, 2016 at 3:59 PM, Jeffrey Sarnoff 
wrote:

> Is this what you want, or are you looking for a more general way to
> construct nxn matrices like this 4x4 matrix, or something else?
>
> julia> m = [ [0,1,2,3] [1,0,4,5] [2,3,0,6] [4,5,6,0] ]
> 4×4 Array{Int64,2}:
>  0  1  2  4
>  1  0  3  5
>  2  4  0  6
>  3  5  6  0
>
>
> On Friday, August 19, 2016 at 9:01:06 AM UTC-4, Ahmed Mazari wrote:
>>
>> Yes but it doesn't allow me to set the diagonal to 0 ??
>>
>> On Fri, Aug 19, 2016 at 2:55 PM, Michael Borregaard 
>> wrote:
>>
>>> You can build the matrix as normal, then specify that the upper triangle
>>> is undefined by
>>> mat = LowerTriangular(mat) # where mat is a Matrix of any eltype.
>>>
>>
>>


Re: [julia-users] Re: lower triangular matrix in julia

2016-08-19 Thread Ahmed Mazari
Yes but it doesn't allow me to set the diagonal to 0 ??

On Fri, Aug 19, 2016 at 2:55 PM, Michael Borregaard 
wrote:

> You can build the matrix as normal, then specify that the upper triangle
> is undefined by
> mat = LowerTriangular(mat) # where mat is a Matrix of any eltype.
>


Re: [julia-users] Re: lower triangular matrix in julia

2016-08-19 Thread Ahmed Mazari
definelty l used to work with R. l don't care by NA , l did that beauce
m[1,2]= m[2,1] and so on

On Fri, Aug 19, 2016 at 2:56 PM, Jeffrey Sarnoff 
wrote:

> I'm guessing you have worked with R, because the example you give uses NA
> as if it were an integer.  Julia does not have NA that way (there is
> special class of Nullable types that either are valued with e.g. an Int or
> else isnull .. probably you do not need that right now).
> Would using floating point values and using the floating point NaN
> (not-a-number, a special floating point value) where you have NA work, or
> is this NA more like 'dont care', where replacing them with 0s would work?
>
>
>
> On Friday, August 19, 2016 at 8:31:21 AM UTC-4, Ahmed Mazari wrote:
>>
>> Hello,
>>
>> l have the number of columns equals the number of rows . and the the
>> diagonal is esqual to zero .  How can l build this matrix  ?
>> #mat
>> # [,1] [,2] [,3] [,4]
>> #[1,]   0   NA   NA   NA
>> #[2,]1   0   NA   NA
>> #[3,]24   0   NA
>> #[4,]356   0
>>
>>
>> thank you
>>
>


[julia-users] lower triangular matrix in julia

2016-08-19 Thread Ahmed Mazari
Hello,

l have the number of columns equals the number of rows . and the the 
diagonal is esqual to zero .  How can l build this matrix  ?
#mat
# [,1] [,2] [,3] [,4]
#[1,]   0   NA   NA   NA
#[2,]1   0   NA   NA
#[3,]24   0   NA
#[4,]356   0


thank you


Re: [julia-users] Re: Using gemm!()

2016-07-20 Thread Ahmed Mazari
Thanks a lot it's more clear for me

On Wed, Jul 20, 2016 at 4:01 PM, Stefan Karpinski 
wrote:

> This page is a bit more helpful:
>
>
> http://www.ibm.com/support/knowledgecenter/SSFHY8_5.2.0/com.ibm.cluster.essl.v5r2.essl100.doc/am5gr_hsgemm.htm
>
> N = no transform
> T = transpose
> C = conjugate transpose
>
> On Wed, Jul 20, 2016 at 9:48 AM, Ahmed Mazari 
> wrote:
>
>> l still don't understand 'N' , 'T' . Any clarifications please ?
>>
>> TRANSA = 'N' or 'n',  op( A ) = A.
>>
>>  TRANSA = 'T' or 't',  op( A ) = A'.
>>
>> TRANSB = 'N' or 'n',  op( B ) = B.
>>
>>  TRANSB = 'T' or 't',  op( B ) = B'.
>>
>>  TRANSB = 'C' or 'c',  op( B ) = B'.
>>
>>
>> On Wed, Jul 20, 2016 at 3:36 PM, Steven G. Johnson > > wrote:
>>
>>>
>>>
>>> On Wednesday, July 20, 2016 at 9:33:37 AM UTC-4, Ahmed Mazari wrote:
>>>>
>>>> l'm new to julia. l want to use the Blas package. To do so, the meaning
>>>> of the two first parameters of gemm function are less evident for me What
>>>> the parameters 'N', 'T' represent?
>>>>
>>>
>>> Those exactly correspond to arguments to the Fortran dgemm subroutine (
>>> http://www.math.utah.edu/software/lapack/lapack-blas/dgemm.html).  They
>>> indicate whether the matrices are to be treated as transposed.
>>>
>>>
>>>>  BLAS.gemm!('N', 'T', lr,  alpha, A, B, beta, C)
>>>>
>>>> What is the difference between BLAS.gemm and BLAS.gemm! ?
>>>>
>>>
>>> The convention in Julia is that appending an exclamation mark (e.g.
>>> gemm!) indicates that the function modifies one of its arguments in-place,
>>> whereas gemm allocates a new array for the result.
>>>
>>
>>
>


Re: [julia-users] Re: Using gemm!()

2016-07-20 Thread Ahmed Mazari
loool

On Wed, Jul 20, 2016 at 4:12 PM, Stefan Karpinski 
wrote:

> It's a weird API but this is how it's been done since antiquity.
>
> On Wed, Jul 20, 2016 at 10:04 AM, Ahmed Mazari 
> wrote:
>
>> Thanks a lot it's more clear for me
>>
>> On Wed, Jul 20, 2016 at 4:01 PM, Stefan Karpinski 
>> wrote:
>>
>>> This page is a bit more helpful:
>>>
>>>
>>> http://www.ibm.com/support/knowledgecenter/SSFHY8_5.2.0/com.ibm.cluster.essl.v5r2.essl100.doc/am5gr_hsgemm.htm
>>>
>>> N = no transform
>>> T = transpose
>>> C = conjugate transpose
>>>
>>> On Wed, Jul 20, 2016 at 9:48 AM, Ahmed Mazari 
>>> wrote:
>>>
>>>> l still don't understand 'N' , 'T' . Any clarifications please ?
>>>>
>>>> TRANSA = 'N' or 'n',  op( A ) = A.
>>>>
>>>>  TRANSA = 'T' or 't',  op( A ) = A'.
>>>>
>>>> TRANSB = 'N' or 'n',  op( B ) = B.
>>>>
>>>>  TRANSB = 'T' or 't',  op( B ) = B'.
>>>>
>>>>  TRANSB = 'C' or 'c',  op( B ) = B'.
>>>>
>>>>
>>>> On Wed, Jul 20, 2016 at 3:36 PM, Steven G. Johnson <
>>>> stevenj@gmail.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Wednesday, July 20, 2016 at 9:33:37 AM UTC-4, Ahmed Mazari wrote:
>>>>>>
>>>>>> l'm new to julia. l want to use the Blas package. To do so, the
>>>>>> meaning of the two first parameters of gemm function are less evident for
>>>>>> me What the parameters 'N', 'T' represent?
>>>>>>
>>>>>
>>>>> Those exactly correspond to arguments to the Fortran dgemm subroutine (
>>>>> http://www.math.utah.edu/software/lapack/lapack-blas/dgemm.html).
>>>>> They indicate whether the matrices are to be treated as transposed.
>>>>>
>>>>>
>>>>>>  BLAS.gemm!('N', 'T', lr,  alpha, A, B, beta, C)
>>>>>>
>>>>>> What is the difference between BLAS.gemm and BLAS.gemm! ?
>>>>>>
>>>>>
>>>>> The convention in Julia is that appending an exclamation mark (e.g.
>>>>> gemm!) indicates that the function modifies one of its arguments in-place,
>>>>> whereas gemm allocates a new array for the result.
>>>>>
>>>>
>>>>
>>>
>>
>


Re: [julia-users] Re: Using gemm!()

2016-07-20 Thread Ahmed Mazari
l still don't understand 'N' , 'T' . Any clarifications please ?

TRANSA = 'N' or 'n',  op( A ) = A.

 TRANSA = 'T' or 't',  op( A ) = A'.

TRANSB = 'N' or 'n',  op( B ) = B.

 TRANSB = 'T' or 't',  op( B ) = B'.

 TRANSB = 'C' or 'c',  op( B ) = B'.


On Wed, Jul 20, 2016 at 3:36 PM, Steven G. Johnson 
wrote:

>
>
> On Wednesday, July 20, 2016 at 9:33:37 AM UTC-4, Ahmed Mazari wrote:
>>
>> l'm new to julia. l want to use the Blas package. To do so, the meaning
>> of the two first parameters of gemm function are less evident for me What
>> the parameters 'N', 'T' represent?
>>
>
> Those exactly correspond to arguments to the Fortran dgemm subroutine (
> http://www.math.utah.edu/software/lapack/lapack-blas/dgemm.html).  They
> indicate whether the matrices are to be treated as transposed.
>
>
>>  BLAS.gemm!('N', 'T', lr,  alpha, A, B, beta, C)
>>
>> What is the difference between BLAS.gemm and BLAS.gemm! ?
>>
>
> The convention in Julia is that appending an exclamation mark (e.g. gemm!)
> indicates that the function modifies one of its arguments in-place, whereas
> gemm allocates a new array for the result.
>


[julia-users] Using gemm!()

2016-07-20 Thread Ahmed Mazari
 

l'm new to julia. l want to use the Blas package. To do so, the meaning of 
the two first parameters of gemm function are less evident for me What the 
parameters 'N', 'T' represent?

 BLAS.gemm!('N', 'T', lr,  alpha, A, B, beta, C)

What is the difference between BLAS.gemm and BLAS.gemm! ? 


Re: [julia-users] Re: How to install 0.4.5 on Ubuntu?

2016-07-15 Thread Ahmed Mazari
yes but it installs  the version 0.5

On Fri, Jul 15, 2016 at 4:39 PM, Uwe Fechner 
wrote:

> Did you try:
>
> sudo add-apt-repository ppa:staticfloat/juliareleases
>
> sudo add-apt-repository ppa:staticfloat/julia-deps
>
> sudo apt-get update
>
> sudo apt-get install julia
>
>
> You need to have the correct ppa enabled!
>
>
> Uwe
>
>
> On Friday, July 15, 2016 at 3:49:04 PM UTC+2, Ahmed Mazari wrote:
>>
>> How to install julia 0.4.6 in ubuntu ?
>>
>> l tried
>> sudo apt-get install julia=v0.4.6 but it's not working
>>
>> On Sunday, May 22, 2016 at 12:27:37 PM UTC+2, Nils Gudat wrote:
>>>
>>> Slightly stupid question from someone who is forced to use Linux on a
>>> server: how can I get the latest stable version as opposed ot the dev
>>> release?
>>> I followed the instructions from here (
>>> http://julialang.org/downloads/platform.html), but always end up with a
>>> 44-day old 0.5 master version installed...
>>>
>>


[julia-users] Re: How to install 0.4.5 on Ubuntu?

2016-07-15 Thread Ahmed Mazari
How to install julia 0.4.6 in ubuntu ?

l tried  
sudo apt-get install julia=v0.4.6 but it's not working

On Sunday, May 22, 2016 at 12:27:37 PM UTC+2, Nils Gudat wrote:
>
> Slightly stupid question from someone who is forced to use Linux on a 
> server: how can I get the latest stable version as opposed ot the dev 
> release? 
> I followed the instructions from here (
> http://julialang.org/downloads/platform.html), but always end up with a 
> 44-day old 0.5 master version installed...
>


Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-05 Thread Ahmed Mazari
l'm looking for hierarchical structure (like this one tree) to generate
artifiicial data

On Tue, Jul 5, 2016 at 12:47 PM, Ahmed Mazari 
wrote:

> train a neural net with these data.
>
> On Tue, Jul 5, 2016 at 12:43 PM, Andre Bieler 
> wrote:
>
>> Can you tell me what you will be doing with this tree after everything is
>> set up correctly?
>
>
>


Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-05 Thread Ahmed Mazari
train a neural net with these data.

On Tue, Jul 5, 2016 at 12:43 PM, Andre Bieler 
wrote:

> Can you tell me what you will be doing with this tree after everything is
> set up correctly?


Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-05 Thread Ahmed Mazari
the objective is to get 100 (leafs) vectors (which are not equal in length)
of data  from child and root.
initial data is in the root
then the data is divided between childs (the size of each vector may varies
from 1 child to another)
each child share it's data with its own leaf (the size of each vector may
varies from on leaf to another )

the objective is to do clustering l need this architecture. Any ideas how
to get this data ?


Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-05 Thread Ahmed Mazari
But l have encountered a problem when distributing data from root to child 
then to leafs. l'm looking for something like this: 

*level 0root :   *data= rand(1)  # generate 1 random 
values
*level 1  10 child *  for each child attribute a certain number of 
generated values , divide the data generated in the root between the childs
   for example child 1= 1000  child 2 = 500  child3 = 750   
child4 = 1500 child 5= 2000 child6 = 250 child 7= 1500 child8 = 500 child 
9= 1000 child 10= 500
the sum gives you = 1 values

*level 2 leafs  :*
each child has a certin number of leafs . let's suppose that child 1 has 4 
leafs. then data should be shared as folllows :
child 1 = 1000 values

leaf 1 = 500  leaf 2 = 200 leaf 3= 100  leaf 4 = 150 leaf 5 = 50   and the 
sum equal to 1000 (child 1 = 1000 values)

do that for each child.

l'm trying to do that since yesterday but l failed, l keep trying , any 
help please


On Monday, July 4, 2016 at 2:09:25 PM UTC+2, Andre Bieler wrote:
>
> Well for 1) this is pretty much exactly what is being done in my example 
> code.
> The difference is that it prints out the content of "data". (But I put the 
> index of
> each child into that "data" varialbe)
>
> My suggestion is that you insert a new field in the MyNode type, this 
> variable
> can then hold an index. E. g. for child1 this index is 1, etc.
>
> Then do the same thing my example does in the end, but print out this 
> index instead
> of data.
> I think you should try implementing this on you own, it will probably help 
> you understand
> what is going on in the code. If you have problems doing so you can come 
> back with more
> questions.
>
> Cheers,
> Andre
>


Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-05 Thread Ahmed Mazari
hello, 

l fixed the problem by adding a function called data_node() as follows :

function data_node(node)
 
  println("data : ", node.data)
  println("index ", node.index)
end

for i in 1:nChildren
for k in 1:root.child[i].nchild
  data_node(root.child[i].child[k])
end
end



On Monday, July 4, 2016 at 4:39:54 PM UTC+2, Ahmed Mazari wrote:
>
> The idea that comes to my mind is the following : 
> add a new variable to MyNode type wich is  index, 
> type MyNode{T}
> data::Vector{T}
> level::Int
> child :: Vector{MyNode}
> nchild :: Int
> index :: Int
> end
>
> function node_info(node)
>   println("Level: ", node.level)
>   println("nChildren: ", node.nchild)
>   println("data : ", node.data)
>   println("index ", node.index)
> end
>
> # set an empty list to store the leafs of each child 
> for i in 1:nChildren 
>  list_leafs_of_child[i]= Int64[] # for instance list_leafs_of_child[1] = 
> [2, 5,4,9 ..]
> end
>
> for i in 1:nChildren
> for j in 1:nGrandChildren
>  if contains(grand_children_list[i], j) # check whether  j is contained 
> in grand_children_list[i] if so add j to the list of leafs of child[i]
> # contains is a function in julia 
>   list_leafs_of_child[i]= [list_leafs_of_child  j]  #  add j to the list 
>   , j : new element , list_leafs_of_child  : the ancient list 
> end
> end
>
> but it's not working my function is not well my loop is not well defined. 
> sorry for these stupid questions. l'm a dummy in julia hope that l don't 
> bother you
>
>
>
>
> On Monday, July 4, 2016 at 2:09:25 PM UTC+2, Andre Bieler wrote:
>>
>> Well for 1) this is pretty much exactly what is being done in my example 
>> code.
>> The difference is that it prints out the content of "data". (But I put 
>> the index of
>> each child into that "data" varialbe)
>>
>> My suggestion is that you insert a new field in the MyNode type, this 
>> variable
>> can then hold an index. E. g. for child1 this index is 1, etc.
>>
>> Then do the same thing my example does in the end, but print out this 
>> index instead
>> of data.
>> I think you should try implementing this on you own, it will probably 
>> help you understand
>> what is going on in the code. If you have problems doing so you can come 
>> back with more
>> questions.
>>
>> Cheers,
>> Andre
>>
>

[julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-05 Thread Ahmed Mazari

hello, 

l fixed the problem by adding a function called data_node() as follows :

function data_node(node)
 
  println("data : ", node.data)
  println("index ", node.index)
end

for i in 1:nChildren
for k in 1:root.child[i].nchild
  data_node(root.child[i].child[k])
end
end


On Wednesday, June 29, 2016 at 4:53:55 PM UTC+2, Ahmed Mazari wrote:
>
> Hello ,
>  
>
> I need to implement a tree in Julia with depth of l=3. Initially the root 
> node has a vector of m=1 random values (k=rand(m)).Then this vector is 
> divided into k=10 partitions where each node child has a vector of n=1000 
> values. Finally the leafs are connected to a given child node.
>
> each partition (child node) has 10 leafs where each leaf has a vector of 
> g= 100 values. Since each child node has a vector of 1000 values.this 
> latter is shared with its leafs 100 values for each leaf. so the structure 
> of the tree is as follows: 
>
>
>
> level 0 root node : vector of 1 values
>
> level 110 child node each one of 1000 
> values
>
> level 2   10 leafs for each child node of 100 values (that 
> means we have in total we have 100 leafs )
>
>
>
> Thank you for helps
>


Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-04 Thread Ahmed Mazari
The idea that comes to my mind is the following : 
add a new variable to MyNode type wich is  index, 
type MyNode{T}
data::Vector{T}
level::Int
child :: Vector{MyNode}
nchild :: Int
index :: Int
end

function node_info(node)
  println("Level: ", node.level)
  println("nChildren: ", node.nchild)
  println("data : ", node.data)
  println("index ", node.index)
end

# set an empty list to store the leafs of each child 
for i in 1:nChildren 
 list_leafs_of_child[i]= Int64[] # for instance list_leafs_of_child[1] = 
[2, 5,4,9 ..]
end

for i in 1:nChildren
for j in 1:nGrandChildren
 if contains(grand_children_list[i], j) # check whether  j is contained in 
grand_children_list[i] if so add j to the list of leafs of child[i]
# contains is a function in julia 
  list_leafs_of_child[i]= [list_leafs_of_child  j]  #  add j to the list   
, j : new element , list_leafs_of_child  : the ancient list 
end
end

but it's not working my function is not well my loop is not well defined. 
sorry for these stupid questions. l'm a dummy in julia hope that l don't 
bother you




On Monday, July 4, 2016 at 2:09:25 PM UTC+2, Andre Bieler wrote:
>
> Well for 1) this is pretty much exactly what is being done in my example 
> code.
> The difference is that it prints out the content of "data". (But I put the 
> index of
> each child into that "data" varialbe)
>
> My suggestion is that you insert a new field in the MyNode type, this 
> variable
> can then hold an index. E. g. for child1 this index is 1, etc.
>
> Then do the same thing my example does in the end, but print out this 
> index instead
> of data.
> I think you should try implementing this on you own, it will probably help 
> you understand
> what is going on in the code. If you have problems doing so you can come 
> back with more
> questions.
>
> Cheers,
> Andre
>


Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-04 Thread Ahmed Mazari
Hello Andre thantk you a lot , when l run the code l think it's gives what
l'm looking for. but l have trouble to understand the code in order to add
the following instruction :
1) l need to print a list of leaf of each child by retrieving the indexes
:  for example
child 1 :  [leaf 1,  leaf 5 , ]
child 2 : [leaf 3, leaf 4 ]

2) for each leaf print the following :
leaf 1 is linked to child 3
leaf 2 is linked to child 5
and so on

On Sun, Jul 3, 2016 at 4:35 PM, Andre Bieler 
wrote:

> and maybe someday I will be smart enough for syntax highlighting... maybe..
>


Re: [julia-users] How to store tuples in different jld files

2016-07-04 Thread Ahmed Mazari
Helo TIm, yes beacause at that time l haven't discovered yet julia google
group

On Mon, Jul 4, 2016 at 1:00 AM, Tim Holy  wrote:

> Duplicated in
> http://stackoverflow.com/questions/38147946/julia-how-to-store-tuples-in-different-files
>
> --Tim
>
> On Friday, July 1, 2016 7:48:34 AM CDT Ahmed Mazari wrote:
> > Hello,
> >
> > l want to store each tuple X[p] in a different file
> > # X[1] in mini_batch1.jld X[2] in mini_batch2.
> >  # but my code below stores (duplicate) all the tuple of X[p] in the
> files
> > created.
> >
> >
> >
> > let's see an example :
> >
> > m= 100 k= 3 # number of tuples or partition
> > y=rand_gen(m,k)
> >
> > (3,[[-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,
> > 1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,-
> > 1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0],[1.0,-1.0,-1.0,-1.0,
> > 1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,-1.
> > 0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,
> > -1.0,-1.0],[1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.
> > 0,1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,1.
> > 0,1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0]])
> >
> > l want to have in : mini_batch1 the first tuple
> > [-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,
> > 1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,-1.0,
> > 1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0]
> >
> >
> > mini_batch2 the second tuple [1.0,-1.0,-1.0,-1.0,1.0,1.0,1.
> > 0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,
> > -1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,-1.0]
> >
> > and so on.
> >
> > However my code do the job of creating the mini_batches files but fail to
> > store one by one tuple. how can l fix that ?
> > workspace()
> > using JLD, HDF5
> > function gen_random(m,k)
> >
> > # m the length of the vector , for instance m=10 and k the number of
> > partitions let's set k=16
> >
> > s = rand(m)
> > # Pkg.add("JLD"), Pkg.add("HDF5") these two packages are needed in order
> to
> > store our vectors in files under the extension jld
> >
> >  # allow to convert each random number to -1 or 1
> >
> > X=float_to_binary(s)
> > parts= kfoldperm(length(X),k)
> > # l want to store each tuple X[p] in a different file
> > # X[1] in mini_batch1.jld X[2] in mini_batch2.
> > # but my code below store all the tuple X[p] in the files created.
> > for p in 1:length(parts)
> > file =jldopen(@sprintf("my path to file/mini_batch%d.jld", p),"w")
> > write(file, "X", [X[p] for p in parts])
> > close(file)
> > end
> > return [X[p] for p in parts]
> >
> > function float_to_binary(s,level=0.4)
> >  for i=1:length(s)
> >  s[i] = s[i] > level ? 1.0 : -1.0
> >  end
> >  file = jldopen("/my path/mydata.jld", "w")
> >  write(file, "s", s) # alternatively, say "@write file A"
> >  close(file)
> >  return s
> >  end
> >
> >
> >  function kfoldperm(l,k)
> >  n,r = divrem(l,k)
> >  b = collect(1:n:l+1)
> >  for i in 1:length(b)
> >  b[i] += i > r ? r : i-1
> >  end
> >  p = randperm(l)
> >  return [p[r] for r in [b[i]:b[i+1]-1 for i=1:k]]
> >
> >
> >  end
>
>
>


Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-01 Thread Ahmed Mazari
l don't understand your code!!  how do you connect each child to its leafs ?

On Fri, Jul 1, 2016 at 4:42 PM, Ahmed Mazari 
wrote:

> ha  you should just reply from the google group rather than from your
> inbox mail. then click on { } to highlight the syntax
>
> On Fri, Jul 1, 2016 at 4:38 PM, Andre Bieler 
> wrote:
>
>> ah for &^%$@@ sake how do you enable syntax highlighting?? I thought
>> ```julia would do the trick??
>> If you tell me the secret I can re-post my previous message more nicely :)
>>
>
>


[julia-users] How to store tuples in different jld files

2016-07-01 Thread Ahmed Mazari
Hello,

l want to store each tuple X[p] in a different file
# X[1] in mini_batch1.jld X[2] in mini_batch2.
 # but my code below stores (duplicate) all the tuple of X[p] in the files 
created. 



let's see an example : 

m= 100 k= 3 # number of tuples or partition 
y=rand_gen(m,k)

(3,[[-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,
1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,-
1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0],[1.0,-1.0,-1.0,-1.0,
1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,-1.
0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,
-1.0,-1.0],[1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.
0,1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,1.
0,1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0]])

l want to have in : mini_batch1 the first tuple 
[-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,
1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,-1.0,
1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0] 


mini_batch2 the second tuple [1.0,-1.0,-1.0,-1.0,1.0,1.0,1.
0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,
-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,-1.0] 

and so on. 

However my code do the job of creating the mini_batches files but fail to 
store one by one tuple. how can l fix that ?
workspace() 
using JLD, HDF5
function gen_random(m,k) 

# m the length of the vector , for instance m=10 and k the number of 
partitions let's set k=16

s = rand(m)
# Pkg.add("JLD"), Pkg.add("HDF5") these two packages are needed in order to 
store our vectors in files under the extension jld 

 # allow to convert each random number to -1 or 1

X=float_to_binary(s)
parts= kfoldperm(length(X),k)
# l want to store each tuple X[p] in a different file
# X[1] in mini_batch1.jld X[2] in mini_batch2.
# but my code below store all the tuple X[p] in the files created.
for p in 1:length(parts)
file =jldopen(@sprintf("my path to file/mini_batch%d.jld", p),"w")
write(file, "X", [X[p] for p in parts]) 
close(file)
end
return [X[p] for p in parts]

function float_to_binary(s,level=0.4)
 for i=1:length(s)
 s[i] = s[i] > level ? 1.0 : -1.0
 end
 file = jldopen("/my path/mydata.jld", "w")
 write(file, "s", s) # alternatively, say "@write file A"
 close(file)
 return s
 end


 function kfoldperm(l,k)
 n,r = divrem(l,k)
 b = collect(1:n:l+1)
 for i in 1:length(b)
 b[i] += i > r ? r : i-1 
 end
 p = randperm(l)
 return [p[r] for r in [b[i]:b[i+1]-1 for i=1:k]]


 end




[julia-users] How to store tuples in different files?

2016-07-01 Thread Ahmed Mazari
 Hello,


 
# X[1] in mini_batch1.jld X[2] in mini_batch2. # but my code below 
stores (duplicate) all the tuple of X[p] in the files created. 



let's see an example : 

m= 100 k= 3 # number of tuples or partition 
y=rand_gen(m,k)




(3,[[-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0],[1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,-1.0],[1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0]])


 

l want to have in : mini_batch1 the first tuple 
[-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0]
 







 

mini_batch2 the second tuple 
[1.0,-1.0,-1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,-1.0]
 


and so on. 





However my code do the job of creating the mini_batches files but fail to 
store one by one tuple. how can l fix that ?
workspace() 
using JLD, HDF5
function gen_random(m,k) 

# m the length of the vector , for instance m=10 and k the number of 
partitions let's set k=16

s = rand(m)
# Pkg.add("JLD"), Pkg.add("HDF5") these two packages are needed in order to 
store our vectors in files under the extension jld 

 # allow to convert each random number to -1 or 1

X=float_to_binary(s)
parts= kfoldperm(length(X),k)
# l want to store each tuple X[p] in a different file
# X[1] in mini_batch1.jld X[2] in mini_batch2.
# but my code below store all the tuple X[p] in the files created.
for p in 1:length(parts)
file =jldopen(@sprintf("my path to file/mini_batch%d.jld", p),"w")
write(file, "X", [X[p] for p in parts]) 
close(file)
end
return [X[p] for p in parts]

function float_to_binary(s,level=0.4)
 for i=1:length(s)
 s[i] = s[i] > level ? 1.0 : -1.0
 end
 file = jldopen("/my path/mydata.jld", "w")
 write(file, "s", s) # alternatively, say "@write file A"
 close(file)
 return s
 end


 function kfoldperm(l,k)
 n,r = divrem(l,k)
 b = collect(1:n:l+1)
 for i in 1:length(b)
 b[i] += i > r ? r : i-1 
 end
 p = randperm(l)
 return [p[r] for r in [b[i]:b[i+1]-1 for i=1:k]]


 end





Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-01 Thread Ahmed Mazari
ha  you should just reply from the google group rather than from your inbox
mail. then click on { } to highlight the syntax

On Fri, Jul 1, 2016 at 4:38 PM, Andre Bieler 
wrote:

> ah for &^%$@@ sake how do you enable syntax highlighting?? I thought
> ```julia would do the trick??
> If you tell me the secret I can re-post my previous message more nicely :)
>


Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-01 Thread Ahmed Mazari
1) yes they are of the same type as root and child . the leaf is the last
level of the tree so it doesn't have any child
2) yes no children with zero leaf at least one leaf

On Fri, Jul 1, 2016 at 4:37 PM, Andre Bieler 
wrote:

> I think I start seeing what you want. A few questions:
>
> 1) Can the leafs be of the same type as the root and child?
> 2) Does every child need to have one child at least? (= no child with zero
> leafs)
>
> you can do the following:
>
> ```julia
>
> # this generates a list of empty vectors that can hold MyNode types, each
> of these vectors
> # will then be filled with leafs
> # once all vectors are filled with leafs we can distribute them to the
> children
>
> all_leafs = Any[MyNode[] for i in 1:nChildren]
>
> for i in 1:100
>   childIndex = rand(1:nChildren) # pick to which child this leaf will go
>   #create your leaf here with necessary stuff like above
>   leaf=MyNode(data,level, MyNode[], 0)
>   push!(all_leafs[childIndex], leaf)
> end
> ```
>
> then you can distribute those leafs:
>
> ```julia
>
> for i in 1:nChildren
>   root.child[i].child = all_leafs[i]
> end
> ```
>


[julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-01 Thread Ahmed Mazari
Let's define the function that allows to associate randomly a certain 
number of leafs for each child under a constraint : the total number of 
leafs is 100 and the function that allows to add_link between each child 
with its leafs. Please don't hesitate to modify the code, there is some 
improvement to do. hope the problem is more clear for you

function random_edges(nleafs) #nleafs = 100
x=rand(1:nleafs,(1,10)) # (1,10) to tell that we have 10 childs 
while (sum(x) !== nleafs) # the while loop allows to get a tuple of 10 
values where each value represents the number of 
  # of leafs for each child where sum(x)= nleafs
x=rand(1:nleafs,(1,10))
end
return x
end

y=random_edges(100)
1x10 Array{Int64,2}:
 3  1  7  5  13  7  30  6  18  10
sum(y)
100

# child 1 has 3 leafs , child 2 has 1 leaf, child 3 has 7 leafs .. 
child 10 has ten leafs 

# here we need to define the function that allows to link each child to its 
leafs and transfer data from each child to its leafs
# some improvement to do 



x=random_edges(100) # 100 number of leafs needed


function  add_leafs!(childs,x)  #x : the output of the function 
random_edges  childs : the output of the function add_children!
data =  child data ? # the data of each child  
level = childs.level +1  # since the level of child is 1 then the level of 
leafs is 2
h = 0
   for i in 1:length(x)
   while h < x[i]# how to link each child to its 
leafs. for example i= 1 x[1]= 3 then we need to have 3 leafs for child 1 
and so on ...
  leaf=MyNode(data,level, MyNode[], 0)
   push!(childs.leaf,leaf)
   h += 1
end 
   end
 
   
end



Thank you
On Friday, July 1, 2016 at 12:41:09 PM UTC+2, Andre Bieler wrote:
>
> Well the child can also have children, just like in your graph you 
> attached. This is then one level down in your graph. 
>
> Note that the root is of the same type as the children. (MyNode can be 
> parent, child, grandchild etc.) The children are just put inside the root. 
> Then you can continue and put children into these children. This is how you 
> get the tree structure.
>
> I hope this is somehow clear.
>
> Best,
> Andre
>
>

[julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-01 Thread Ahmed Mazari
Let's define the function that allows to associate randomly a certain 
number of leafs for each child under a constraint : the total number of 
leafs is 100.

function random_edges(nleafs) #nleafs = 100
x=rand(1:nleafs,(1,10)) # (1,10) to tell that we have 10 childs 
while (sum(x) !== nleafs) # the while loop allows to get a tuple of 10 
values where each value represents the number of 
  # of leafs for each child where sum(x)= nleafs
x=rand(1:nleafs,(1,10))
end
return x
end

y=random_edges(100)
1x10 Array{Int64,2}:
 3  1  7  5  13  7  30  6  18  10
sum(y)
100

# child 1 has 3 leafs , child 2 has 1 leaf, child 3 has 7 leafs .. 
child 10 has ten leafs 

# here we need to define the function that allows to link each child to its 
leafs and transfer data from each child to its leafs
# some improvement to do 
function  add_leafs!(childs,nleafs)  # x: the tuple that containts the 
values of random edges (random_edges(nleafs))
 
level = childs.level +1  # since the level of child is 1 then the level of 
leafs is 2
for i in 1:nleafs
   leaf=MyNode(data,level, MyNode[], 0)
   push!(childs.leaf,leaf)
end
   
end


x=random_edges(100)


function  add_leafs!(childs,x)  #x : the output of the function 
random_edges  childs : the output of the function add_children!
data =  child data ? # the data of each child  
level = childs.level +1  # since the level of child is 1 then the level of 
leafs is 2
h = 0
   for i in 1:length(x)
   while h < x[i]# how to link each child to its 
leafs. for example i= 1 x[1]= 3 then we need to have 3 leafs for child 1 
and so on ...
  leaf=MyNode(data,level, MyNode[], 0)
   push!(childs.leaf,leaf)
   h += 1
end 
   end
 
   
end





On Friday, July 1, 2016 at 12:41:09 PM UTC+2, Andre Bieler wrote:
>
> Well the child can also have children, just like in your graph you 
> attached. This is then one level down in your graph. 
>
> Note that the root is of the same type as the children. (MyNode can be 
> parent, child, grandchild etc.) The children are just put inside the root. 
> Then you can continue and put children into these children. This is how you 
> get the tree structure.
>
> I hope this is somehow clear.
>
> Best,
> Andre
>
>

Re: [julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-01 Thread Ahmed Mazari
l do follow you well. but for the leafs when l add 100 leafs (level 2), how
can you capture what are the leafs of a given children.

let's dive in more details :
level 1  child 1   child 2 .child 10
level 2 leaf 1  leaf 2 ...   leaf 10

for example : can we retrieve who are the leafs of a given child k :
l want something like that   child k such that k [1..10]  has leaf m leaf
m+2 leaf  m+ 59
for instance child 6 has leaf 67  leaf 3 leaf 45 leaf 2
   child 1 has leaf 5 leaf 7  leaf 56
 .
 .
  .
child 10

the total number of leafs is 100 in level 2. the childs dont't have the
same number of leafs :
for examples child 1  has 3 leafs
   child 2 has 6 leafs
  the sum of leafs = 100

the number of leafs for each child is done randomly.

Hope you get the point

thanks a lot for your helps Andre

On Fri, Jul 1, 2016 at 12:41 PM, Andre Bieler 
wrote:

> Well the child can also have children, just like in your graph you
> attached. This is then one level down in your graph.
>
> Note that the root is of the same type as the children. (MyNode can be
> parent, child, grandchild etc.) The children are just put inside the root.
> Then you can continue and put children into these children. This is how you
> get the tree structure.
>
> I hope this is somehow clear.
>
> Best,
> Andre


[julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-07-01 Thread Ahmed Mazari
hi,
l don't understand what you're doing here.  add_children!() need to have as 
a parameter a root (node parent) not child, isn't it ?
*for child in root.child*
*  add_children!(child, 10)*
*end*



On Wednesday, June 29, 2016 at 4:53:55 PM UTC+2, Ahmed Mazari wrote:
>
> Hello ,
>  
>
> I need to implement a tree in Julia with depth of l=3. Initially the root 
> node has a vector of m=1 random values (k=rand(m)).Then this vector is 
> divided into k=10 partitions where each node child has a vector of n=1000 
> values. Finally the leafs are connected to a given child node.
>
> each partition (child node) has 10 leafs where each leaf has a vector of 
> g= 100 values. Since each child node has a vector of 1000 values.this 
> latter is shared with its leafs 100 values for each leaf. so the structure 
> of the tree is as follows: 
>
>
>
> level 0 root node : vector of 1 values
>
> level 110 child node each one of 1000 
> values
>
> level 2   10 leafs for each child node of 100 values (that 
> means we have in total we have 100 leafs )
>
>
>
> Thank you for helps
>


Re: [julia-users] How to make a tree datastructure with vector data in JULIA ?

2016-06-30 Thread Ahmed Mazari
l took  a  look at Datastructures.jl there is no tree implementation except 
balance_tree.jl
https://github.com/JuliaLang/DataStructures.jl/blob/master/src/balanced_tree.jl
which is not what l'm looking for

On Wednesday, June 29, 2016 at 5:16:23 PM UTC+2, Mauro wrote:
>
> I think you need to show us what you've tried so far.  Also have a look 
> at Datatstructures.jl for inspiration. 
>
> On Wed, 2016-06-29 at 11:29, Ahmed Mazari  > wrote: 
> > Hello , 
> > 
> > 
> > I need to implement a tree in Julia with depth of l=3. Initially the 
> root 
> > node has a vector of m=1 random values (k=rand(m)).Then this vector 
> is 
> > divided into k=10 partitions where each node child has a vector of 
> n=1000 
> > values. Finally the leafs are connected to a given child node. 
> > 
> > each partition (child node) has 10 leafs where each leaf has a vector of 
> g= 
> > 100 values. Since each child node has a vector of 1000 values.this 
> latter 
> > is shared with its leafs 100 values for each leaf. so the structure of 
> the 
> > tree is as follows: 
> > 
> > 
> > 
> > level 0 root node : vector of 1 values 
> > 
> > level 110 child node each one of 1000 
> values 
> > 
> > level 2   10 leafs for each child node of 100 values 
> (that 
> > means we have in total we have 100 leafs ) 
> > 
> > 
> > 
> > Thank you for helps 
>


[julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-06-30 Thread Ahmed Mazari


On Thursday, June 30, 2016 at 2:12:30 PM UTC+2, Ahmed Mazari wrote:
>
> Hi Andre. 
> You will fnd attached my files and a picture that illustrates the tree 
> structure l'm looking for.
> file 1 : somme comments on your codes
> file 2 : my code to be improved.
>
> For the part of your code. We should add child, number of child and data.
> the structure seems to be appropriate from my point of view 
>
> type MyNode{T}
> data:: T
> level::Int
> child :: Vector{MyNode}
> nchild :: Int
> nLeafs::Int
> leafs::Vector{MyNode}
> end
>  1) What's the purpose of this line  MyNode() = MyNode(0,0,MyNode[]) ?
> 2) for level 0 it's the root as you defined it :
>
> root = MyNode(0,N, [MyNode() for i in 1:N])
>
> but for level 1 it will be child :
> child= MyNode(..)
>
> for node in root.child
>   # we have to link root to child and transferer data 
>  # need to define function addEdge()
>
>
> end
>
> level 2 : 
> leaf= MyNode(..)
>  
> for leaf in root.leaf
>   # we have to link childs to their own leafs and transferer data 
>  # need to define function addEdge()
> end
>
>
>
> On Wednesday, June 29, 2016 at 7:47:25 PM UTC+2, Andre Bieler wrote:
>>
>> Not very elegant, but maybe something like this?
>>
>> type MyNode
>> level::Int
>> nLeafs::Int
>> leafs::Vector{MyNode}
>> end
>>
>> MyNode() = MyNode(0,0,MyNode[])
>>
>> N = 100
>> root = MyNode(0,N, [MyNode() for i in 1:N])
>>
>> then you can go on and define the 1st level with a for loop and so on.
>> Because it is only 3 levels I guess you can manually set it up, otherwise
>> you want to use recursive functions or so.
>>
>> For 2nd level:
>>
>> for node in root.leafs
>>   do_whatever
>> end
>>
>

files2.jl
Description: Binary data


file1.jl
Description: Binary data


[julia-users] Re: How to make a tree datastructure with vector data in JULIA ?

2016-06-30 Thread Ahmed Mazari
Hi Andre. 
You will fnd attached my files and a picture that illustrates the tree 
structure l'm looking for.
file 1 : somme comments on your codes
file 2 : my code to be improved.

For the part of your code. We should add child, number of child and data.
the structure seems to be appropriate from my point of view 

type MyNode{T}
data:: T
level::Int
child :: Vector{MyNode}
nchild :: Int
nLeafs::Int
leafs::Vector{MyNode}
end
 1) What's the purpose of this line  MyNode() = MyNode(0,0,MyNode[]) ?
2) for level 0 it's the root as you defined it :

root = MyNode(0,N, [MyNode() for i in 1:N])

but for level 1 it will be child :
child= MyNode(..)

for node in root.child
  # we have to link root to child and transferer data 
 # need to define function addEdge()


end

level 2 : 
leaf= MyNode(..)
 
for leaf in root.leaf
  # we have to link childs to their own leafs and transferer data 
 # need to define function addEdge()
end



On Wednesday, June 29, 2016 at 7:47:25 PM UTC+2, Andre Bieler wrote:
>
> Not very elegant, but maybe something like this?
>
> type MyNode
> level::Int
> nLeafs::Int
> leafs::Vector{MyNode}
> end
>
> MyNode() = MyNode(0,0,MyNode[])
>
> N = 100
> root = MyNode(0,N, [MyNode() for i in 1:N])
>
> then you can go on and define the 1st level with a for loop and so on.
> Because it is only 3 levels I guess you can manually set it up, otherwise
> you want to use recursive functions or so.
>
> For 2nd level:
>
> for node in root.leafs
>   do_whatever
> end
>


Re: [julia-users] How to make a tree datastructure with vector data in JULIA ?

2016-06-30 Thread Ahmed Mazari
Hi Mauro look at the discussion below

On Wednesday, June 29, 2016 at 5:16:23 PM UTC+2, Mauro wrote:
>
> I think you need to show us what you've tried so far.  Also have a look 
> at Datatstructures.jl for inspiration. 
>
> On Wed, 2016-06-29 at 11:29, Ahmed Mazari  > wrote: 
> > Hello , 
> > 
> > 
> > I need to implement a tree in Julia with depth of l=3. Initially the 
> root 
> > node has a vector of m=1 random values (k=rand(m)).Then this vector 
> is 
> > divided into k=10 partitions where each node child has a vector of 
> n=1000 
> > values. Finally the leafs are connected to a given child node. 
> > 
> > each partition (child node) has 10 leafs where each leaf has a vector of 
> g= 
> > 100 values. Since each child node has a vector of 1000 values.this 
> latter 
> > is shared with its leafs 100 values for each leaf. so the structure of 
> the 
> > tree is as follows: 
> > 
> > 
> > 
> > level 0 root node : vector of 1 values 
> > 
> > level 110 child node each one of 1000 
> values 
> > 
> > level 2   10 leafs for each child node of 100 values 
> (that 
> > means we have in total we have 100 leafs ) 
> > 
> > 
> > 
> > Thank you for helps 
>


[julia-users] How to make a tree datastructure with vector data in JULIA ?

2016-06-29 Thread Ahmed Mazari
Hello ,
 

I need to implement a tree in Julia with depth of l=3. Initially the root 
node has a vector of m=1 random values (k=rand(m)).Then this vector is 
divided into k=10 partitions where each node child has a vector of n=1000 
values. Finally the leafs are connected to a given child node.

each partition (child node) has 10 leafs where each leaf has a vector of g= 
100 values. Since each child node has a vector of 1000 values.this latter 
is shared with its leafs 100 values for each leaf. so the structure of the 
tree is as follows: 



level 0 root node : vector of 1 values

level 110 child node each one of 1000 values

level 2   10 leafs for each child node of 100 values (that 
means we have in total we have 100 leafs )



Thank you for helps