Ups, It looks like I made a mistake. its 0.02 with G now, wow, just a sec, let me recheck :)
Regards, On Wed, Dec 14, 2011 at 4:07 PM, Alexander Epifanov <[email protected]> wrote: > Thank you very much, its very interesting, it loads very fast, but the > speed of f is the same like initial programm: ~0.12-13sec. > That if why I suppose it is not possible to make it faster, but it is > also very good result. > > Regards, > > > On Wed, Dec 14, 2011 at 3:56 PM, Raul Miller <[email protected]> wrote: >> F is faster than f, for me: >> >> F=: < (~.m) {~ ((}.m) {./. l)&I. >> >> Note that this assumes that m and l are in sorted order and that pip >> '0.0.0.0' is not the second element of m (but I think the code already >> makes these assumptions). >> >> And G is faster than F, for me: >> >> G=: 2 | (,(~.}.m) ,.~ (}.m) {./. l) I. ] >> >> (f -: F) ips >> 1 >> (f -: G) ips >> 1 >> >> -- >> Raul >> >> On Wed, Dec 14, 2011 at 5:14 AM, Alexander Epifanov <[email protected]> >> wrote: >>> Hello again, >>> Here my optimized version with ints, its 1.5 faster then float solution. >>> http://dl.dropbox.com/u/34917039/ip.j >>> >>> The main thing: it is much faster than K! >>> >>> Could you let me know, is it possible to optimize time of "f" function? >>> I tryed to represent IP like 4 ints: 192 168 1 1, but this solution >>> works much slower. >>> >>> ips.txt: file with ip addresses >>> ipr.txt: file with ip ranges: ip,ip >>> >>> And the other thing I cannot understand: >>> 5?5 >>> 4 1 0 2 3 >>> 10?5 >>> |domain error >>> | 10 ?5 >>> ??? >>> >>> Thank you, >>> >>> On Fri, Dec 9, 2011 at 10:53 PM, Alexander Epifanov <[email protected]> >>> wrote: >>>> Hello, >>>> >>>> On Fri, Dec 9, 2011 at 3:11 PM, Raul Miller <[email protected]> wrote: >>>>> On Fri, Dec 9, 2011 at 7:50 AM, Alexander Epifanov >>>>> <[email protected]>wrote: >>>>> >>>>>> Hello, >>>>>> >>>>>> I made my first application on J. >>>>>> I was surprised that it works faster than K: >>>>>> >>>>>> pip =: 256 #. x:@:".;._2@:,&'.' >>>>>> ips =: pip"1 (_1&}.;._2 (1!:1<'ips.txt')) >>>>>> iprs =: |:pip;._1 "1 (','&,)"1 (_1&}.;._2 (1!:1<'ipr.txt')) >>>>>> i =: /:{.iprs >>>>>> l =: i{{.iprs >>>>>> r =: i{{:iprs >>>>>> m =: 0,(>./ @: {.&r)"0 (1+i.#l) >>>>>> f =: <: m {~ I.~&l >>>>>> 6!:2 'f"1 ips' >>>>>> >>>>>> But I suppose that it could be better: >>>>>> 1) It uses x:, but IP address could fill int, I found that J does not >>>>>> support unsigned int (K also). >>>>>> But unfortunately, I cannot find the way in J how to convert 4 numbers >>>>>> into signed int i J. >>>>>> >>>>> >>>>> Why are you concerned about data representation type? This works fine: >>>>> >>>>> pip =: 256 #. ".;._2@:,&'.' >>>>> >>>>> >>>> Yes, it works, but 3!:0 pip'192.168.1.1' - float, But I suppose that >>>> int would be faster, I would like to compare. >>>> >>>>>> >>>>>> 2) How is it possible to change m =: 0,(>./ @: {.&r)"0 (1+i.#l) >>>>>> without right brackets? I expected something like ... "0 @: 1 + i.#l, >>>>>> but it does not work. I think that "0 +&1 i.#l is not best solution. >>>>>> >>>>> >>>>> I do not have any ipr.txt so I do not know what domain m is intended for. >>>>> I could guess, but right now I do not understand your question. >>>>> >>>>> >>>>>> 3) ips =: pip"1 (_1&}.;._2 (1!:1<'ips.txt')) is very slow, in pip >>>>>> function, is it possible to make it faster? >>>>>> >>>>> >>>>> Getting rid of x: should make pip faster. I also suspect you want >>>>> something like this: >>>>> >>>>> ips=: pip;._2 (1!:1 <'ips.txt') -. CR >>>> Thanks! it works twice faster. >>>>> >>>>> Or: >>>>> >>>>> ips=: 256 #. 0&".;._2 ' ' (I.@e.&('.',CR)@])} 1!:1<'ips.txt' >>>>> >>>>> >>>>>> 4) I cannot find in VOC is I. binary search or something like that? >>>>>> >>>>> >>>>> Typically, yes. >>>>> >>>>> -- >>>>> Raul >>>>> ---------------------------------------------------------------------- >>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>>> >>>> >>>> -- >>>> Regards, >>>> Alexander. >>> >>> >>> >>> -- >>> Regards, >>> Alexander. >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > > > -- > Regards, > Alexander. -- Regards, Alexander. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
