Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- KX Community
- Discussion Forums
- KX Tech
- sparse arrays

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

sparse arrays

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2008.04.05 04:04 PM

8 REPLIES 8

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2008.04.05 04:47 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2008.04.25 05:11 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2008.05.23 03:46 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2008.05.28 10:05 AM

felix

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2008.07.22 09:57 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2008.07.22 01:49 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2008.07.23 06:23 AM

I made a mistake: "count d" always return 10000. The correct way to

detect collision is "count distinct key d".

To have exactly 10000 distinct points, this works better:

q)v:{[B;L;N]mod[;B](L-1)div[;B]\N} / Base, Length, Numbers

q)n:10000

q)d:(flip v[100;3](0-n)?1000000)!n?1000f

q)count distinct key d

10000

I also experimented with tables:

q)t:(flip`x`y`z!v[100;3](0-n)?1000000)!([]val:n?1000f)

q)5#t

x y z | val

--------| --------

86 20 79| 226.4462

51 63 95| 735.3732

46 70 42| 903.7595

80 13 39| 58.31545

17 53 88| 944.2269

It seems that for insertion and access, tables are faster than

dictionaries:

q)\t i:0;do[2000;(i+:1;d[1,1,i]:1.5)]

4149

q)\t i:0;do[2000;(i+:1;t[1,1,i]:1.5)]

409

q)\t i:0;do[2000;(i+:1;d[1,1,i])]

2062

q)\t i:0;do[2000;(i+:1;t[1,1,i])]

258

But I can't figure out the syntax to delete specific keys from

dictionaries and tables where the keys are not atomic:

q)d _ (1 1 1)

'type

q)t _ (1 1 1)

'type

q)\t delete from `t where x=1,y=1,z<10000 / this works though...

0

Any suggestions on deletion? Are there other reasons to prefer

dictionaries over tables?

Swee Heng

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2008.07.23 10:23 AM

Main Office Contacts

**EMEA**

Tel: +44 (0)28 3025 2242

**AMERICAS**

Tel: +1 (212) 447 6700

**APAC**

Tel: +61 (0)2 9236 5700

Useful Information

Resources

Popular Links

Follow Us

KX. All Rights Reserved.

KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.