Posts by RHER WOLF • 1,529 points
54 posts
-
0
votes0
answers31
viewsQ: Is it possible to make a static library (.lib) with inline function?
Uso Visual Studio 2019 Community. I asked on the forum and received no answers. I want to know if it is possible (if yes, how) in VC++ to declare (no body) a function or methods in a class in a ".…
-
1
votes1
answer85
viewsQ: How to create a good GCL to do Random function?
I know it’s rediscovering the wheel, but I want to know how I can implement in my own way a nice linear congruent generator to draw integer numbers from 0 to 2^B-1. How to choose constants, how many…
-
2
votes1
answer85
viewsA: How to create a good GCL to do Random function?
Linear congruent generators for drawing First, know that Gcls (linear congruent/congruent generators) are generators of recursive sequences of integer elements in which applies to each element to…
-
-2
votes1
answer148
viewsA: Allocating to the heap is so bad? If so, why would we use it?
Because the stack stores static data sequentially, it does not require deep control of where data is allocated to then allocate in empty location and release, it is always on top of the stack that…
-
0
votes0
answers67
viewsQ: How to implement in C++ and use in C# in VS?
EDIT: I want to implement in C++ (no limitations, using intrinsics, inlines, optimizing and everything else normally), choose what in what has been implemented is visible in . NET (C# at least) and…
-
2
votes1
answer84
viewsQ: How to resignify bytes without Undefined behavior?
Details In Assembly, C, C++, C# with unsafe and other languages it is possible to reinterpret binary code at the address as of different type from the original. Convert type int* for float* in C,…
-
1
votes1
answer40
viewsQ: Fast even random float within range
I did the following lcg (linear congruency generator) to draw unsigned int from 0x00000000 to 0xFFFFFFFF uniformly. Just for testing, I used the seed equal to zero and raffling the first five…
-
1
votes1
answer40
viewsA: Fast even random float within range
Surely one can exchange the Typecast of the drawn integer and the division for two integer operations and the binary code conversion. I considered the compilation optimizations and took the…
-
3
votes1
answer510
viewsA: Best worst case sorting algorithm
We have to be careful with expectations and realities when dealing with arrays. As they are structures without so much dynamics, we find in them complications and inconveniences in implementations…
-
3
votes1
answer510
viewsQ: Best worst case sorting algorithm
I want to know which algorithm has the best performance when dealing with its worst case compared to others dealing with each with its own worst case, all applied in array ordering. To better…
-
2
votes2
answers82
viewsA: What is the real complexity behind Sleep Sort compared to the others?
From what I know its origin is "supposedly" unknown because the author is not known. Proceeds? Matheus, if I’m not mistaken this algorithm has its first mention in a job interview report on Google…
-
3
votes1
answer93
viewsA: CHALLENGE: Spline algorithm(s) with derivative continuity(s)
I do not know a widely studied Spline algorithm for this purpose, so I intend to develop a new one gradually. What motivated me to ask, solve and still register here in stackoverflow was I could not…
-
3
votes1
answer93
viewsQ: CHALLENGE: Spline algorithm(s) with derivative continuity(s)
It is known that a polynomial fn:x->y=c0+x*c1+x²*c2+x³*c3+...+x^n*cn can meet the N=n+1 conditions and from n=1 there is convenience to use in Spline formulas, for example f1 can meet the…
-
1
votes0
answers24
viewsQ: Treat Undefined binary code reading behavior as different types
They say that this inline function code has "Undefined behavior", either by binary codes of the same meaning in float and different in other types, or because the order of storage and use of the…
-
1
votes1
answer78
viewsQ: Fastest way to calculate a/b+c/d with float
You can operate four floats in the formula a/b+c/d (two divisions and a sum) mathematically equivalent to the formula (a*d+b*c)/(b*d) (three products, one division and one sum). It is known that…
-
0
votes0
answers64
viewsQ: CHALLENGE: MQO curve adjustment or similar with minimization of other types of error measurements
Context The MQO (ordinary least squares) method is known to receive: a function model f parameter x (which can represent several parameters) from a model with coefficients c[1], c[2], ..., c[o],…
-
9
votes1
answer276
viewsA: CHALLENGE: Algorithm for updating rectilinear motion uniformly varied aiming inertia at a certain end point
As I figured out a way to do this, I’ll post it as an answer to my own question. Still, I’m open to more answers. I will even use a one-dimensional approach and if solutions are found appropriate to…
-
8
votes1
answer276
viewsQ: CHALLENGE: Algorithm for updating rectilinear motion uniformly varied aiming inertia at a certain end point
Question I want an algorithm that updates (from an instant to another, with a certain time interval between the two) a uniformly varied movement aiming at a final value making the fastest possible…
-
1
votes1
answer180
viewsA: Fast calculation of square root and its multiplicative inverse in float
Introducing Algorithms derived from 0x5F3759DF begin by using the so-called "magic numbers" to form integer binary code float which will approximate the solution and can then refine the accuracy…
-
0
votes1
answer180
viewsQ: Fast calculation of square root and its multiplicative inverse in float
Knowing the algorithm "0x5F3759DF" (or "fast inverse square root"), we easily imagine a gross number of variants of it to calculate square root and inverse multiplicative of it in single-Precision…
-
3
votes1
answer469
viewsA: How complex is the algorithm?
For each batch loop, we usually assume a factor in asymptotic notation and of course the impulse leads us to believe that cases like this are O(n*n)=O(n²), as if each loop applied a linear factor,…
-
1
votes1
answer116
viewsQ: How do you make an array of Labels in C/C++?
It is a fact that exists in Assembly (Nasm) and it is a fact that this is a quick way to follow to a point of the program among several. Here is an example code for x64 where you choose one of five…
-
10
votes2
answers1397
viewsA: How to calculate the value of a polynomial function at an arbitrary point?
Full Polynomials In cases of full polynomials, I believe it is more recommended to structure the polynomial in the form of an array of coefficients, making each cell a component monomial of the…
-
2
votes1
answer186
viewsA: What is the benefit of a classification algorithm being stable?
There are cases where a new element in a structure has the same sort key value as an existing one and it is more convenient to place it right after it, as in cases where it is fairer when what comes…
-
1
votes1
answer322
viewsA: How to test the execution time of a code in Visual Studio 2017?
Take into account that certain optimizations can affect performance more than you think. For example, if a variable is defined, initialized, modified and everything else but all useless (because its…
-
3
votes3
answers337
viewsA: What’s wrong with allocating memory with new and then not erasing?
The role of the operator new is to allocate a memory region (heap, not the execution stack) to the data and invoke in each cell the constructor of that data type. This means that each time the…
-
1
votes2
answers466
viewsA: Is it wrong to mix struct with class in C++?
It is quite normal and common to create classes with structure type fields. struct Point2D { float x , y ; } ; class Transform { Point2D translation ; float xAxisRotationAngle ; float…
-
1
votes1
answer30
viewsA: Is it valid to convert an array to a class/struct?
Rodrigo, the most guaranteed way to successfully convert array to structure is to create a structure constructor and an assignment operation. Thus, you determine how it is done and avoid problems.…
-
1
votes1
answer236
viewsA: How to make a MDC algorithm with just sum and subtraction?
Without comparison operations, there is no way to stop the algorithm, so I assume that other arithmetic operations are prohibited, not prohibiting comparison operations. OK? To begin with, we…
-
1
votes3
answers254
viewsA: Logic to compare four values and find the smallest
Note that the way you implemented it is possible to need more than three comparisons. It is possible to find minimum of four values with only three comparisons in any circumstance (i.e., with better…
-
2
votes1
answer657
viewsA: How to make dynamic display in HTML+PHP?
I figured out how to do it, without the need for ajax, javascript, table and others. I’ll explain with the example. I made the whole square matrix dynamic interface in the file "index.php". First, I…
-
0
votes1
answer657
viewsQ: How to make dynamic display in HTML+PHP?
I’m studying HTML and PHP, but there are things I’m not able to figure out how to do. After all, how do I get input data to process them? Like on the keyboard with those text fields <input…
-
-1
votes1
answer167
viewsQ: Problems in "Hello, world!" in PHP
It sounds funny, but it’s true. I made my first code in PHP and tested it, but it didn’t come out what I expected. See the image with the program windows used in this test. In short, I don’t know…
-
0
votes1
answer160
viewsQ: How to rotate nodes in balanced binary search trees
What is the correct way to rotate two nodes (A) and (B) connected in a binary search tree to balance it?
asked RHER WOLF 1,529 -
0
votes1
answer160
viewsA: How to rotate nodes in balanced binary search trees
Call the rotated nodes (a) and (b). In addition, the pointer (P) is the root pointer, (Q) is the left pointer of (b), (R) is the right pointer of (a) and the relation of precedence of knot values is…
answered RHER WOLF 1,529 -
1
votes1
answer815
viewsA: How do I create a char variable with an indeterminate size
Typically, performance arrays of sufficiently large static sizes, such as 999 cells, are used. Still, in C++ has a high-level feature: flow (stream). Streams allow you to add values slowly, with no…
-
2
votes2
answers1368
viewsA: Error: "cannot Convert 'int*' to 'int**"
Miguel, it turns out that &numaboa[2] is the address of the index cell 2. You mean, &numaboa[0] is the same as numaboa (address of the first cell), &numaboa[1] is the same as numaboa+1…
-
2
votes0
answers125
viewsQ: Array sorting with heapsort simulating multi-child tree
Doubt: To order arrays with heapsort, it is customary to simulate in them trees with up to two children per parent, no longer. My question is whether there are studies, implementations, experiments,…
-
1
votes1
answer441
viewsA: Problem printing matrix c++
As commented, you created fields in the structure but did not assign values in the constructor. When you define something in the constructor, you define local variable (as in any function or…
-
4
votes2
answers112
viewsA: What is the logic behind this challenge?
In short, you need to find out if there are non-negative integers a, b and c such that "score=3*a+6*b+7*c". Instead of seeking the solution mathematically by discovering possible a, b, and c, you…
-
5
votes3
answers1585
viewsA: How to generate large random numbers in C++?
You have several options to generate very large numbers. First, you can draw multiple numbers and merge into one. But be careful not to create non-uniform generators and use as if they were. For…
-
0
votes2
answers1485
viewsA: Problems with function that returns character array in C++
Leonardo, it seems that in a good part you are confusing things from one language to another. I will explain to you the mistakes I found. char retorno[20] = criaVetor ; First, function call has…
-
3
votes0
answers92
viewsQ: Optimization of poorly compiled
I set up Visual Studio to compile VC++ with /Ox and compiled this code (with more others that were omitted to simplify). union { unsigned long long u64 ; unsigned short u16[4] ; } x ; union {…
-
1
votes1
answer497
viewsA: C++: Data structure / Queue
To begin with, if it is an exercise in data structures then one is expected to create a sort of queue structure. For example, // Tipo estrutura de fila struct Queue { int iStt ; // Índice de início…
-
2
votes1
answer3318
viewsA: How do you use Cin.get() in C++?
The method returns a type int value equal to the character read in the output stream, not exclusively for cin but for any istream. char c = (char)cin.get() ; The above code does the same as the…
-
1
votes1
answer92
viewsA: Algorithm for AST
Simple. You identify in the expression the last operator to be operated. Associate to this operator all its operands properly, each one structured as expression. Then you treat each of these…
-
2
votes1
answer92
viewsQ: Function with variable number of parameters via template
I know that templates in function definitions do, for each configuration it makes possible, compile a distinct function. I want to know if it is possible to create functions of varied number of…
-
-1
votes2
answers1619
viewsA: About headers in C++
If I create a test file. h, and another test.cpp, as the C++ compiler does to relate the test.cpp file to the test file. h, that is, what are the criteria used? What prevents the test settings. h in…
-
3
votes2
answers101
viewsA: I need an explanation for the error in this C++ script
error: lvalue required as left operand of assignment This means that you are trying to save a number in a place that is impossible to save. It turns out that enum is to create enumeration, that is,…
-
1
votes1
answer161
viewsA: C++: Vector division<unsigned char>
You can implement algorithms learned in school. But in your case you want to make an adaptation where you work with each uchar of the vector being a base digit 256, correct? In addition, one must…