Questions tagged [precompute]

11 questions
8
votes
5 answers

Pythonic way to only do work first time a variable is called

my Python class has some variables that require work to calculate the first time they are called. Subsequent calls should just return the precomputed value. I don't want to waste time doing this work unless they are actually needed by the user. So…
hoju
  • 28,392
  • 37
  • 134
  • 178
7
votes
3 answers

Using referential-transparency to pre-compute values in haskell

Let's say we have a program like this : list = [1..10000000] main = print $ sum list I want this to be compiled such that the executable just prints 50000005000000, without taking as much time and effort. Basically, any expression that will be…
Karan
  • 559
  • 5
  • 12
6
votes
1 answer

Precomputed matrix for fitting with scikit neighbors/radius classification

I work with Scikit-Learn's nearest neighbors/radius classification with a precomputed metric. That means, I pass a n_samples_train x n_samples_train matrix of pairwise distances to the classifier's fit-method. Now I wonder why this has to be done.…
pennibenni
  • 61
  • 3
4
votes
1 answer

Comparing string distance based on precomputed hashes

I have a large list (over 200,000) of strings that I'd like to compare to a given string. The given string is inserted by a user, so it may be slightly incorrect. What I was hoping to do was create some kind of precomputed hash on each string on…
Brad
  • 9,113
  • 10
  • 44
  • 68
2
votes
2 answers

Precompute weights for multidimensional linear interpolation

I have a non-uniform rectangular grid along D dimensions, a matrix of logical values V on the grid, and a matrix of query data points X. The number of grid points differs across dimensions. I run the interpolation multiple times for the same grid G…
2
votes
2 answers

precomputing user-defined functions in postgresql

I'm trying to precompute a user-defined function on a per row basis. The idea is I have JSON object as a text object in one of the fields, and I want to parse out some other 'fields' from it, which can be returned in queries just like any other true…
1
vote
1 answer

Firebird compute field value in trigger from query

I'm trying to make this trigger work: CREATE trigger trig_tbl_art for tbl_art active before update position 0 AS begin IF (NEW.e OLD.e) THEN IF (NEW.f = OLD.f) THEN NEW.f = SELECT (NEW.e)*CAST(row_b AS NUMERIC(9,2)) FROM table_a WHERE…
Ed.C
  • 798
  • 1
  • 6
  • 17
1
vote
0 answers

Limitations of prebaked soft shadows

I'm working for 2 months on prebaking PCSS of nVidia with cubeTextures in WebGL. I have succeeded in implementing the beast in real time. Prebaking it finally works too, but with some obvious artifacts. To be brief, lower I highlight the main…
MrBooks
  • 85
  • 10
1
vote
1 answer

Generate precomputed arrays using templates?

Is there a good pattern that will let me use templates to generate a precomputed array from a given an element type, desired length, and custom function f(int index)? Consider this C-style implementation. #define FORLIST_1(fOfi) (fOfi)(0) #define…
VoidStar
  • 5,241
  • 1
  • 31
  • 45
0
votes
3 answers

guidance on precomputed SQL attributes

Often I deal with aggregate or parent entities which have attributes derived from their constituent or children members. For example: The byte_count and packet_count of a TcpConnection object is computed from the same attributes of its two…
pilcrow
  • 56,591
  • 13
  • 94
  • 135
0
votes
1 answer

How to use ELKI for DBSCAN with precomputed distance matrix

I've a precomputed distance matrix for all the points in my database. I'm trying to invoke ELKI gui with following command: /usr/share/java/elki.jar -dbc.in xml_files.1000 -dbc.filter FixedDBIDsFilter …
Yantra
  • 287
  • 1
  • 4
  • 9