Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Efficient general purpose 1D lookup table?
Replies: 7   Last Post: Jan 6, 2014 11:58 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Paul

Posts: 263
Registered: 2/23/10
Re: Efficient general purpose 1D lookup table?
Posted: Dec 11, 2013 11:51 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Sunday, December 8, 2013 9:05:23 PM UTC-5, Steven Lord wrote:
><paul.domaskis_AT_gmail.com> wrote:
>> I was in fact using a similar approach as your non-sparse lookup
>> table. Since the allowable input values are not continguous, it
>> would be nice if the input argument didn't have to be continuous
>> (matrix indexes have to be).

>
> I'm not sure what you mean here. In a sparse matrix, only the
> nonzero elements are stored. If you have a nonzero element in row 1
> and a nonzero element in row 1000000, that sparse matrix stores just
> those two nonzero values.


Yes, but you still get a valid return value (zero) when the index points to a zero value. I don't want to have to trap zeros because zero is one of the valid values to be returned in a lookup.

>> ...And it would be
>> good if I could cause some kind of abnormality like use NaNs in
>> place of the zeros in a sparse matrix.

>
> The FULL command is just to display the results nicely. It's not
> necessary if you want to work with the values.
>
> sparseFoundValues = lookupTable(valuesToFind, 1); for k =
> 1:length(interpolationLocations) % Do something with
> interpolationLocations(k) and sparseFoundValues(k) end % or just
> work with the whole vectors
> plot(interpolationLocations,sparseFoundValues)


Understood, thanks. However, it seems to me that I would have to work with full matrix just to stick NaNs into locations where the input argument should be invalid. If I understood correctly.

>> Currently, I avoid the issue by restricting myself to contigous
>> input values starting from 1. Strictly speaking, I could encounter
>> situations where that isn't the case, so I was hoping to write code
>> that handles those situations without adding to much to the code
>> (and ideally without departing from vectorization).




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.