I am using eig-gen function from the armadillo library and getting the left and right eigenvectors/eigenvalues together, meaning the elements are appearing as (1,2), (3,4) .
Is there a way to access only the left eigenvectors/eigenvalues at one time since I want to perform manipulation on them ?
If not, how to access corresponding left and right elements from these dual elements ?
[answer withdrawn, as upstream documentation no longer describes the function mentioned in the answer]
Related
I've been studying up on graphs using the Adjacency List implementation, and I am reading that adding an edge is an O(1) operation.
This makes sense if you are just tacking an edge on to the Vertex's Linked List of edges, but I don't understand how this could be the case so long as you care about removing the old edge if one already exists. Finding that edge would take O(V) time.
If you don't do this, and you add an edge that already exists, you would have duplicate entries for that edge, which means they could have different weights, etc.
Can anyone explain what I seem to be missing? Thanks!
You're right at your complecxity analysis. Find if edge already exist is truly O(V). But notice that adding this edge even if existed is still O(1).
You need to remember that having 2 edges with the same source an destination are valid input to graph - even with different weights (maybe not even but because).
That way adding edge to adjacency-list-graph is O(1)
What people usually do to have both optimal search time complexity and the advantages of adjacency lists is to use an array of hashsets instead of an array of lists.
Alternatively,
If you want a worst-case optimal solution, use RadixSort to order the
list of all edges in O(v+e) time, remove duplicates, and then build
the adjacency list representation in the usual way.
source: https://www.quora.com/What-are-the-various-approaches-you-can-use-to-build-adjacency-list-representation-of-a-undirected-graph-having-time-complexity-better-than-O-V-*-E-and-avoiding-duplicate-edges
could anyone tell me that
is it right way if i calculate the crc by the method given below:
i did this because dataword length is large.
is it right?
The bottom set of divisions are what you want for a CRC, and arrive at the correct remainders. Your quotients each need one more bit, but they are not used anyway.
The top division was not completed, but it is not relevant, since you need to append the four zeros first as you did in the bottom left, or the four-bit CRC as you did in the bottom right.
Ultimately, You are doing the same thing what a division does. Refer https://www.wikihow.com/Divide-Binary-Numbers binary division for more. However, the data word to be sent to the receiver should not be altered.
When I assign a system array of doubles to an ilnumerics double array, the values are rounded off to nearest integer. This happens particularly for only large arrays.
Is there any way in ILnumerics to specify up to how many decimals the rounding should occur?
The following screenshot shows the problem . Sample_pulsedata is double array of length 1860 which I am assigning to sample_ydata.
The elements are not really rounded. The effect rather comes from the way the elements are displayed in Visual Studios data tips. ILNumerics tries to find a common scale factor which allows to display all elements in an array aligned.
In your example - presumably - there exist large values at higher indices, which are not shown currently (scroll down in order to find them). These elements cause the scale factor to be 1/10^4. This is indicated in the first line, index [0]: '(:;:) 1e+004'. The 32.57 therefore must get rounded to 33 in order to fit into the 4 digits after the decimal point. '4' is a fixed value in ILNumerics and cannot easily get changed.
The actual values of the array elements are not affected, of course. You can use the Watch window to show only the interesting part of the array, without the rounding effect:
sample_ydata["0:13"]
Or, even better, use the ILNumerics Array Visualizer in order to visualize your data graphically. This not only gives a nice overview of the whole array but also prevents from such artefacts as you encountered.
How big should epsilon be when checking if dot product is close to 0?
I am working on raytracing project, and i need to check if the dot product is 0. But
that will probably never happen, so I want to take it as 0 if its value is in a small
area [-eps, +eps], but I am not sure how big should eps be?
Thanks
Since you describe this as part of a ray-tracing project, your accuracy needed is likely dictated by the "world coordinates" of a scene, or perhaps even the screen coordinates to which those are translated. Either of these would give an acceptable target for absolute error in your calculation.
It might be possible to backtrack from that to the accuracy required in the intermediate calculations you are doing, such as forming an inner product which is supposed "theoretically" to be zero. For example, you might be trying to find a shortest path (reflected light) between two smooth bodies, and the disappearance of the inner product (perpendicularity) gives the location of a point.
In a case like that the inner product may be a quadratic in the unknowns (location of a point) that you seek. It's possible that the unknowns form a "double root" (zero of multiplicity 2), making the location of that root extra sensitive to the computation of the inner product being zero.
For such cases you would want to get roughly twice the number of digits "zero" in the inner product as needed in the accuracy of the location. Essentially the inner product changes very slowly with location in the neighborhood of a double root.
But your application might not be so sensitive; analysis of the algorithm involved is necessary to give you a good answer. As a general rule I do the inner product in double precision to get answers that may be reliable as far as single precision, but this may be too costly if the ray-tracing is to be done in real time.
There is no definitive answer. I use two approaches.
If you are only concerned by floating point error then you can use a pretty small value, comparable to the smallest floating number that the compiler can handle. In c/c++ you can use the definitions provided in float.h, such as DBL_MIN to check for these numbers. I'd use a small multiple of the number, e.g., 10. * DBL_MIN as the value for eps.
If the problem is not floating point math rounding error, then I use a value that is small (say 1%) compared to the modulus of the smallest vector.
I have this massive array of ints from 0-4 in this triangle. I am trying to learn dynamic programming with Ruby and would like some assistance in calculating the number of paths in the triangle that meet three criterion:
You must start at one of the zero points in the row with 70 elements.
Your path can be directly above you one row (if there is a number directly above) or one row up heading diagonal to the left. One of these options is always available
The sum of the path you take to get to the zero on the first row must add up to 140.
Example, start at the second zero in the bottom row. You can move directly up to the one or diagonal left to the 4. In either case, the number you arrive at must be added to the running count of all the numbers you have visited. From the 1 you can travel to a 2 (running sum = 3) directly above or to the 0 (running sum = 1) diagonal to the left.
0
41
302
2413
13024
024130
4130241
30241302
241302413
1302413024
02413024130
413024130241
3024130241302
24130241302413
130241302413024
0241302413024130
41302413024130241
302413024130241302
2413024130241302413
13024130241302413024
024130241302413024130
4130241302413024130241
30241302413024130241302
241302413024130241302413
1302413024130241302413024
02413024130241302413024130
413024130241302413024130241
3024130241302413024130241302
24130241302413024130241302413
130241302413024130241302413024
0241302413024130241302413024130
41302413024130241302413024130241
302413024130241302413024130241302
2413024130241302413024130241302413
13024130241302413024130241302413024
024130241302413024130241302413024130
4130241302413024130241302413024130241
30241302413024130241302413024130241302
241302413024130241302413024130241302413
1302413024130241302413024130241302413024
02413024130241302413024130241302413024130
413024130241302413024130241302413024130241
3024130241302413024130241302413024130241302
24130241302413024130241302413024130241302413
130241302413024130241302413024130241302413024
0241302413024130241302413024130241302413024130
41302413024130241302413024130241302413024130241
302413024130241302413024130241302413024130241302
2413024130241302413024130241302413024130241302413
13024130241302413024130241302413024130241302413024
024130241302413024130241302413024130241302413024130
4130241302413024130241302413024130241302413024130241
30241302413024130241302413024130241302413024130241302
241302413024130241302413024130241302413024130241302413
1302413024130241302413024130241302413024130241302413024
02413024130241302413024130241302413024130241302413024130
413024130241302413024130241302413024130241302413024130241
3024130241302413024130241302413024130241302413024130241302
24130241302413024130241302413024130241302413024130241302413
130241302413024130241302413024130241302413024130241302413024
0241302413024130241302413024130241302413024130241302413024130
41302413024130241302413024130241302413024130241302413024130241
302413024130241302413024130241302413024130241302413024130241302
2413024130241302413024130241302413024130241302413024130241302413
13024130241302413024130241302413024130241302413024130241302413024
024130241302413024130241302413024130241302413024130241302413024130
4130241302413024130241302413024130241302413024130241302413024130241
30241302413024130241302413024130241302413024130241302413024130241302
241302413024130241302413024130241302413024130241302413024130241302413
1302413024130241302413024130241302413024130241302413024130241302413024
02413024130241302413024130241302413024130241302413024130241302413024130
But I like homework :)
I find it easier to reason about the 'paths' problem when starting from the top, and following the rules the other way around.
This means:
a partial path can be the top zero, or an extended partial path
the extensions of a partial path Pr,c are, unless r is the last row, in which they're complete, the union of
the extensions of Pr,c + P(r+1),c
the extensions of Pr,c + P(r+1),c+1
The 'sum' rule just selects certain of all complete paths.