Retrieve variables and equation from database and solve them [duplicate] - oracle

This question already has answers here:
Algebra equation parser for java
(5 answers)
Closed 9 years ago.
My client wants to save an equation formula in a database (Oracle). In this formula they want to use abbreviations of the variables names (field in a table containing the variables) as a descriptive field to see what the formula uses to calculate the result, but wants to be able to calculate the result of the formula when all the variables have values as well.
This means if they change the formula later, the result has to reflect those changes. They have short and long formulas. e.g.
C=(A+B)/100
D=(E+F)/100
G=(3*C)+(4*D)/7
Do you know any reference to something similar to this?
I'm using jsp and Oracle as stated before.

You are on your own. Oracle will not help you much in parsing equations. For simple things, you can iterate over variables and values using SQL REPLACE function and see if that is good enough for you.

Related

When is a set better than an array? [duplicate]

This question already has answers here:
Set vs Array , difference
(3 answers)
Closed 5 years ago.
I have used lots of time arrays in Ruby. But never get a chance to use set. My question is when Set can be useful and when it is better than an array?
From the documentation, the initial definitions go as follows:
Array: An
integer-indexed collection of objects.
Set: A
collection of unordered values with no duplicates.
In a nutshell, you should use Set when you want to make sure that each element in the collection is unique, you want to test if a given element is present in the collection and you won't require random access to the objects.

Searching for similar columns in a huge csv file [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have a huge csv file which has 5000 columns and 5,000,000 rows. I know that there are some columns in this file which are exactly the same. I want to identify such columns. Please not that I cannot fetch this huge file into the memory and runtime is also important.
Exactly the same?
I suppose you can verify it with hash functions.
step 1 - You can load the 5'000 values of first row and calculate 5'000 hash values; exclude the values (the columns) without a corresponding value.
step 2 - Load the value (only the column survived) and calculate the hash of the concatenation of preceding hash with the loaded value; exclude the values (the columns) without a corresponding value.
following steps: exactly as step 2: load and concatenate/hash, excluding columns without matches.

Reading matrices into Mata

I have some large matrices I want to process in Mata, i.e., typical matrix operations such as inverting, multiplying, etc. These are Stata files with variable names in the first row. Some are quite large, >15 GB. So, the first problem is reading the data. I read something about setting up views, but my version of Stata does not show any help for st_view. The help for Mata talks about opening a file with fopen(), but it's pretty cryptic. I also read something about Mata adding changes to the original data. I'd prefer some strategy that doesn't alter my original data as it takes a long time to create the original matrices. Can someone point me in the right direction?
Some misinformation here!
If your matrix is already read in, fopen() sounds irrelevant to you.
If your matrix consists of variables already in Stata, consider using putmata. However, if variable names really are in the first row (i.e. observation) you may need to take them out and destring.
st_view() is documented; presumably you are just looking in the wrong place. Start at help m4_stata.
Mata won't change your Stata data unless you ask it to.

How to gauge Excel Calculation speed? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am developing an Excel 2010 Application, which contains complex calculations in over 60+ worksheets. When I change certain data in any cell, it takes a lot of time in background calculation (I want the calculation to be automatic).....
Is there any way to find out which formula is taking more time over the other?
What is a better approach to improve performance - multiple simple formulas vs. single complex (MULTISTEP) formula?
i.e.
[STEP-1] E1 = C1 * D1
[STEP-2] F1 = E1 / B1
[STEP-3] G1 = F1 + B1
OR
[SINGLE STEP] G1 = (C1 * D1 / B1) + A1
Suggestion will be appreciated!
Thanks
As for the second part, if you use ordinary non-volatile functions then multiple simple formulas could be better for two reasons:
On simple recalculations (without rebuilding dependency trees) Excel will calculate only the parts that actually changed, e.g. in your single step example if value in A1 changes then Excel will have to recalculate the expression in the parentheses (C1 * D1 / B1) even if values of C1, D1, B1 are unchanged. When you replace that part with a reference to F1, the value of F1 will not be recalculated if only A1 changes its value.
Multiple simple formulas could be better calculated in parallel if you have multiple cores.
another usefull link in addition to MSDN: http://www.decisionmodels.com/calcsecretsc.htm
Volatile functions are evil in very large workbooks, especially OFFSET and INDIRECT. They all are recalculated every time anything changes in a file, and they are always calculated in a single thread. Any cell that depends on a cell with a volatile function becomes volatile as well, because all dependencies have to be recalculated every time a volatile function is recalculated. This viral volatility in a big file could seriously damage performance. Using many simple formulas helps in this case as well, since many dependencies could remain non-volatile.
From the link above:
Some Excel features do not use multithreaded calculation, for example:
Data table calculation (but structured references to tables do use
MTC). User-defined functions (but XLL functions can be
multithread-enabled). XLM functions. INDIRECT, CELL functions that use
either the format2 or address options. GETPIVOTDATA and other
functions referring to PivotTables or cubes. Range.Calculate and
Range.CalculateRowMajorOrder. Cells in circular reference loops.
Once upon a time I inherited a big file that took 30 min to recalculate on a dedicated fast machine and that was due to crazy usage of OFFSETS to access data from a big sheet. Just by moving calculation logic from Excel to Access and importing results via a pivot table I reduced total calculation time to several seconds!
This may help with your first question http://msdn.microsoft.com/en-us/library/ff700515%28v=office.14%29.aspx though as can be seen there your question may be close to being off topic as requiring a book to answer it comprehensively. For your second question I'd guess "no discernible difference".

Data structure for sentence completion suggestions [duplicate]

This question already has answers here:
Algorithm for autocomplete?
(9 answers)
Closed 9 years ago.
If a word is typed in Google, it will show a list of words as suggestions in a drop-down list.
For example, if you type what, it will show what is your name, what is your father's name, what is your college name, etc. in 8 words.
What is a suitable data structure, as well as best way to list those suggestions?
I think the best method is to use a trie where each edge is weighted according to the probability that the next letter correspond to this edge so that first suggestions have higher probabilities.

Resources