spreadsheet: use equation to calculate value - gnumeric

I have a simple table in Gnumeric (but I expect there should be a general solution for all spredsheets). Column B contains numbers (input), and column C should contain values calculated using my equation. For the first cell, the equation is =(B6-C5)*C4. Now I want to drag (expand) the equation down the column, so that all the cells are populated with the solutions. The problem is, the cells C5 and C4 should stay static, only the B cells should go from B6 to B_infinity.... But unfortunately, gnumeric increments all cells, ie
=(B6-C5)*C4
=(B7-C6)*C5
=(B8-C7)*C6
...
whereas, I need the equation to be:
=(B6-C5)*C4
=(B7-C5)*C4
=(B8-C5)*C4
...
How can I tell Gnumeric what I want ?

You can change the cell reference to be abosolute, with a $ symbol:
=(B6-C5)*$C$4

If excel is the same as gnumeric, you need to freeze your references. For the first formula, use:
=(B6-$C$5)*$C$4
After that, fill down this formula and it should be doing what you expected it to do.

Related

At least how many lines are needed to reduce the number in the grid to zero

This is a programming problem.
Suppose we have an n x m array, and each grid contains an integer greater than or equal to 0.
enter image description here
We can choose to draw a vertical line or a horizontal line.
In the grid where this line passes, the number in it will be reduced by one (not less than 0).
Example: If we draw a horizontal line.
enter image description here
So how many lines do we need at least to reduce the numbers in the grid to zero?
I have thought about using brute force search method and dynamic programming method
But there is no clear proof to prove that my idea is right.
Can someone help me solve this problem?
thanks.
I think that the dynamic programming approach is rather clear and provable.
You start with a singleton list of your start grid.
At each stage, you take each grid in the current list and for each row and column in that grid that isn't already completely zero produce a new grid that has all cells in this row or column reduced by one. Then remove duplicates. Count the stages until you have the all-zero grid.
This can be optimized by only producing two new grids for each grid, choosing either a row or column for the highest remaining cell.

In PowerBI, how to expand row values in a matrix and keep showing subtotals

In Power BI, I have the next problem. I have a matrix with subtotals and I want to expand one of the subtotals and continue seeing the value of the rest subtotals, but they disappear when I expand one of the subtotals. How can I do to continue showing those values?
Original Matrix
Expanded Matrix
I have highlighted in yellow where I would like to continue seeing the subtotal (like in the original matrix when it wasn't expanded).
PS: I have the option Row Subtotals On
Thanks!

Dynamic programming matrix exercise

I'm practicing with dynamic programming and I'm trying to solve this exercise http://www.geeksforgeeks.org/collect-maximum-points-in-a-grid-using-two-traversals/
But I can't understand how to use dynamic programming.
My reasoning is to use a table T[n][m] to store the results and in every cells to find the max value to go (corresponding to a cell).
Using the example shown in the link: how do I know at the first cell [0][0] to go to "3" instead of "5"? Using my reasoning the choice is to go to "5" but it's a bad way
You table should not be used to look ahead as you are suggesting. That sounds more like a greedy approach which indeed is not correct. Instead use what you have calculated from previous iterations to do the calculation in the current iteration.
Simplified I would describe the algorithm as:
Initialize a table T[C][C] and initially set all values to 0. Where C is the number of columns.
T[c1][c2] holds the best possible score at the previous row where traveler 1 would be in column c1 and traveler 2 would be in column c2
Then you can just iterate over the rows:
Checking if for row r the travelers can be at their respective positions c1, c2
Fill up a new table tmp, where tmp[c1][c2] is arr[R][c1] + arr[R][c2] + Max(T[c1-1][c2-1], T[c1][c2-1], ..., T[c1+1][c2+1]).
Replace T with tmp
Result: T[0]+T[C-1]
Remark: I did not take care about the case were both travelers are on the same spot and they are not both getting the points. I am assuming this is handled in the checking because we should be able to prove that in the optimal solution c1 < c2 for all rows. (except when C = 1)
Why this is correct:
At row R there are only 9 (3x3) combinations possible starting from the previous row. And for each possible position we always take the best. This means we are actually trying every possible combination for both travelers and we can't miss any better solution.
To wrap up this algorithm is not giving you the path to the best solution, only the best score. You may be confused by this because you intuïtively are looking for a path.
Extra
Is it possible to get the path with this algorithm too?
Yes, but you will need to do some extra work.
Let's say we keep all are calculated T arrays for all rows.
Then we can check for instance the following:
T[R][c1][c2] == arr[R][c1] + arr[R][c2] + T[R-1][c-1][c-2]
This checks if an optimal path is possible if in the previous row both travelers went to the right. In this way we could walk up back to the starting positions.

algorithm for grouping elements from multi dimensional matrix

Hi fellows
I have a question in regards to an algorithm problem I am trying to solve.
The input data to the algorithm is a matrix that can be described as follows:
The matrix has N dimensions, like the one in the attached picture (which has 2 dimensions for example).
There are a number of elements (denoted as c1, .. c5 in the attached sample matrix) that are mapped into the cells of the matrix.
An element can occur in one or more cells in the matrix.
The algorithm should work as follows:
Pick (and then remove) elements from the matrix and group them into buckets of E elements, so that:
the elements in each bucket don't have any common values on any of the dimensions
each element is assigned only into one bucket
For example, referring to the sample matrix attached, if we selected E to be 2, then a possible grouping could be: {c1, c2} ; {c3, c4} and {5} by itself. Check: c1 and c2 (and c3 and c4) don't have any common column or row values in the matrix.
The problem has been doing my head in for some time now and I thought it may be worth asking if some whiz here has a solution.
Thanks

Confirm I understand matrix determinants

Basically I have been trying to forge an understanding of matrix maths over the last few weeks and after reading (and re-reading) many maths heavy articles and documentation I think I have an adequate understanding, but I just wanted to make sure!
The definitions i have ended up with are:
/*
Minor
-----
-A determinant of a sub matrix
-The sub matrix used to calculate a minor can be obtained by removing more then one row/column from the original matrix
-First minors are minors of a sub matrix where only the row and column of a single element have been removed
Cofactor
--------
-The (signed) minor of a single element from a matrix
ie. the minor of element 2,3 is the determinant of the submatrix, of the matrix, defined by removing row 2 and column 3
Determinant
-----------
-1. Choose any single row or column from a Matrix.
2. For each element in the row/column, multiply the value of the element against the First Minor of that element.
3. This result is then multiplied by (-1 raised to the power of the elements row index + its column index) which will give the result of step 2 a sign.
4. You then simply sum all these results to get the determinant (a real number) for the Matrix.
*/
Please let me know of any holes in my understanding?
Sources
http://en.wikipedia.org /Cofactor_(linear_algebra) & /Minor_(linear_algebra) & /Determinant
http://easyweb.easynet.co.uk/~mrmeanie/matrix/matrices.htm
http://www.geometrictools.com/Documentation/LaplaceExpansionTheorem.pdf (the most helpful)
Geometric tools for computer graphics (this may have missing pages, i have the full copy)
Sounds like you understand determinants -- now go forth and write code! Try writing a solver for simultaneous linear equations in 3 or more variables, using Cramer's Rule.
Since you tagged this question 3dgraphics, matrix and vector multiplication might be a good area to explore next. They come up everywhere in 3d graphics programming.

Resources