Tag Info

New answers tagged

-1

(Its more a comment, than a real anwser, but I can't post here it as a comment yet) One of the terms you are searching for is "autocorrelation" (see Wikipedia). You can compare your first element to your second, and the 2nd to the 3rd and so on, in the next round you compare first with third, second with nr 4. basicly you shift the lines in each round one ...


3

I'd try something like symbolic computing where we run the computation over an abstraction of all possible starting states, the goal of this symbolic execution is to produce an abstraction of the ending state, which is then reflective of the computations performed by the set of operations to be optimized. (Because we use an abstraction of all possible ...


2

The most straightforward way would be to track some metadata along with the array, so you end up with a data structure something like this: [{name: "Banana", originalOrder: 2}, {name: "Orange", originalOrder: 1, deleted: true}, {name: "Cherry", new: true}, {name: "Raspberry", new: true}, {name: "Apple", originalOrder: 0}, {name: "Strawberry", ...


24

sizeof(a)/sizeof(t) explicitly codes the type into the expression. You now have the type specified in multiple locations, with no compiler support for ensuring that you're using the same type. So, if you change the base type of the array, but not in the count expression, bingo: your element count is wrong. If you're lucky your program will crash, but if not ...


0

You would probably be well-served looking through the numpy documentation, the library has a lot of optimised ways of doing simple and complex operations on ndarrays that avoid using multiple for-loops. You could just do this to achieve the same thing: import numpy as np total = np.sum(arraytransition) arraytransition_normalised = arraytransition / total ...


1

Here is a revised version: with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Characters; use Ada.Characters; procedure test is type Two_Dimensional_Char_Array is -- Natural range seems more appropriate array (Natural range <>, Natural range <>) of Character; procedure ...


4

The best practice is to use "constructor" function. While the type can be unconstrained, the actual object has to posses some compile time bounds on size (unless you allocate it on heap). You should create additional function for creating this array. Here is how I modified your code and works just fine (do note that I changed indices to be 1 based, as I ...



Top 50 recent answers are included