Re: [julia-users] Different type columns in Matrix
Hi Jeff, Thank you very much your responses, I am sorry I didn't understand your answer because I dont know what does it mean f,g and h. But I want to get this structure and later I have to get by the 3rd column decreasing order in this structure. And than I can use 1 st and 2nd columns together. Another concepts composite type i dont understand. regards Kenan 29 Kasım 2014 Cumartesi 17:09:27 UTC-5 tarihinde Jeff Waller yazdı: > > >> This 3 column are neccessary for later analysis in my work, first and >> second column index and 3rd values. I have to use three columns same time. >> > > Ok right so, whatever the exact expression is, it's going to have the form > > f(A[:,1:2]) > > where f does some indexing function followed sometime later by > > g(A[:,3]) > > where g does some value stuff. > > but you don't have > > h(A[:,1:3]) > > because there's no builtin thing that does both indexing and evaluation > simultaneously > I'm using f g and h just to short-hand describe what's going on, not to > imply > they are actually called f, g, h or even that they're actually formally > functions. So if that's > the case then really why not use A and B? Convenience, Encapsulation? > Sure, that's valid > but I'm suggesting that those two things are even better served by using > composites, because > then you have the type system working for you instead of against you. >
Re: [julia-users] Different type columns in Matrix
> > > This 3 column are neccessary for later analysis in my work, first and > second column index and 3rd values. I have to use three columns same time. > Ok right so, whatever the exact expression is, it's going to have the form f(A[:,1:2]) where f does some indexing function followed sometime later by g(A[:,3]) where g does some value stuff. but you don't have h(A[:,1:3]) because there's no builtin thing that does both indexing and evaluation simultaneously I'm using f g and h just to short-hand describe what's going on, not to imply they are actually called f, g, h or even that they're actually formally functions. So if that's the case then really why not use A and B? Convenience, Encapsulation? Sure, that's valid but I'm suggesting that those two things are even better served by using composites, because then you have the type system working for you instead of against you.
Re: [julia-users] Different type columns in Matrix
Le vendredi 28 novembre 2014 à 22:50 -0800, John Myles White a écrit : > There is no matrix in Julia that satisfies the constraint that one > column is all integers, another column is all integers and the last is > all floats, because all matrices in Julia have a homogeneous type. > > There are several possible solutions: > > (1) Use Array{Any} and then enforce your constaints by hand. > > (2) Use Array{Vector} and store the columns as the entries of an array of > columsn. > > (3) Allow all columns to be floats. Why don't you mention the fourth solution, that is use a DataFrame? Depending one's the objectives, it may be a good solution. Regards > — John > > On Nov 28, 2014, at 10:39 PM, Kenan KARAGÜL wrote: > > > Hi everyone, > > Could you help me any one about this subject. > > > > A=rand(2,3) > > 2x3 Array{Float64,2}: > > 0.650875 0.0649599 0.320412 > > 0.801777 0.633312 0.271399 > > > > a,b,C=findnz(A) > > ([1,2,1,2,1,2],[1,1,2,2,3,3],[0.650875,0.801777,0.0649599,0.633312,0.320412,0.271399]) > > > > I want to get this matrix > > [a b C] --> [Int64 Int64 Float64] > > 1 1 0.650875 > > > > 2 1 > > 0.801777 > > > > 1 2 > > 0.0649599 > > > > 2 2 > > 0.633312 > > > > 1 3 > > 0.320412 > > > > 2 3 > > 0.271399 > > but I can get [a b C] -->[Float64 Float64 Float64] > > 1.0 1.0 0.650875 > > 2.0 1.0 0.801777 > > 1.0 2.0 0.0649599 > > 2.0 2.0 0.633312 > > 1.0 3.0 0.320412 > > 2.0 3.0 0.271399 > > > > Thank you in advance > >
Re: [julia-users] Different type columns in Matrix
Thank you very much your explanations. 29 Kasım 2014 Cumartesi 01:50:55 UTC-5 tarihinde John Myles White yazdı: > > There is no matrix in Julia that satisfies the constraint that one column > is all integers, another column is all integers and the last is all floats, > because all matrices in Julia have a homogeneous type. > > There are several possible solutions: > > (1) Use Array{Any} and then enforce your constaints by hand. > > (2) Use Array{Vector} and store the columns as the entries of an array of > columsn. > > (3) Allow all columns to be floats. > > — John > > On Nov 28, 2014, at 10:39 PM, Kenan KARAGÜL > wrote: > > > Hi everyone, > > Could you help me any one about this subject. > > > > A=rand(2,3) > > 2x3 Array{Float64,2}: > > 0.650875 0.0649599 0.320412 > > 0.801777 0.633312 0.271399 > > > > a,b,C=findnz(A) > > > ([1,2,1,2,1,2],[1,1,2,2,3,3],[0.650875,0.801777,0.0649599,0.633312,0.320412,0.271399]) > > > > > > I want to get this matrix > > [a b C] --> [Int64 Int64 Float64] > > 1 1 0.650875 > > > > 2 1 > > 0.801777 > > > > 1 2 > > 0.0649599 > > > > 2 2 > > 0.633312 > > > > 1 3 > > 0.320412 > > > > 2 3 > > 0.271399 > > but I can get [a b C] -->[Float64 Float64 Float64] > > 1.0 1.0 0.650875 > > 2.0 1.0 0.801777 > > 1.0 2.0 0.0649599 > > 2.0 2.0 0.633312 > > 1.0 3.0 0.320412 > > 2.0 3.0 0.271399 > > > > Thank you in advance > > > >
Re: [julia-users] Different type columns in Matrix
Hi, This 3 column are neccessary for later analysis in my work, first and second column index and 3rd values. I have to use three columns same time. 29 Kasım 2014 Cumartesi 13:01:16 UTC-5 tarihinde Jeff Waller yazdı: > > I'd add one more. > > Or two arrays or a composite with 2 arrays. > > After all whatever is supposed to take advantage of everything being in > one array > is going to have some subtle error when the types change out from under > it moving from > one column to the next. Or you will use Any and it will be horribly slow. > Or you will > never apply the same operation to all columns at once either by design or > as a practical > matter to avoid the problems above in which case why are you using 1 array > in the > first place? >
Re: [julia-users] Different type columns in Matrix
I'd add one more. Or two arrays or a composite with 2 arrays. After all whatever is supposed to take advantage of everything being in one array is going to have some subtle error when the types change out from under it moving from one column to the next. Or you will use Any and it will be horribly slow. Or you will never apply the same operation to all columns at once either by design or as a practical matter to avoid the problems above in which case why are you using 1 array in the first place?
Re: [julia-users] Different type columns in Matrix
There is no matrix in Julia that satisfies the constraint that one column is all integers, another column is all integers and the last is all floats, because all matrices in Julia have a homogeneous type. There are several possible solutions: (1) Use Array{Any} and then enforce your constaints by hand. (2) Use Array{Vector} and store the columns as the entries of an array of columsn. (3) Allow all columns to be floats. — John On Nov 28, 2014, at 10:39 PM, Kenan KARAGÜL wrote: > Hi everyone, > Could you help me any one about this subject. > > A=rand(2,3) > 2x3 Array{Float64,2}: > 0.650875 0.0649599 0.320412 > 0.801777 0.633312 0.271399 > > a,b,C=findnz(A) > ([1,2,1,2,1,2],[1,1,2,2,3,3],[0.650875,0.801777,0.0649599,0.633312,0.320412,0.271399]) > > I want to get this matrix > [a b C] --> [Int64 Int64 Float64] > 1 1 0.650875 > > 2 1 > 0.801777 > > 1 2 > 0.0649599 > > 2 2 > 0.633312 > > 1 3 > 0.320412 > > 2 3 > 0.271399 > but I can get [a b C] -->[Float64 Float64 Float64] > 1.0 1.0 0.650875 > 2.0 1.0 0.801777 > 1.0 2.0 0.0649599 > 2.0 2.0 0.633312 > 1.0 3.0 0.320412 > 2.0 3.0 0.271399 > > Thank you in advance >
[julia-users] Different type columns in Matrix
Hi everyone, Could you help me any one about this subject. A=rand(2,3) 2x3 Array{Float64,2}: 0.650875 0.0649599 0.320412 0.801777 0.633312 0.271399 a,b,C=findnz(A) ([1,2,1,2,1,2],[1,1,2,2,3,3],[0.650875,0.801777,0.0649599,0.633312,0.320412,0.271399]) I want to get this matrix [a b C] --> [Int64 Int64 Float64] 1 1 0.650875 2 1 0.801777 1 2 0.0649599 2 2 0.633312 1 3 0.320412 2 3 0.271399 but I can get [a b C] -->[Float64 Float64 Float64] 1.0 1.0 0.650875 2.0 1.0 0.801777 1.0 2.0 0.0649599 2.0 2.0 0.633312 1.0 3.0 0.320412 2.0 3.0 0.271399 Thank you in advance