« first day (1329 days earlier)      last day (1524 days later) » 

8:34 AM
Hello, noob question: is there any behind the scene conversion for doubles, or floats, when used in arithmetic with compelx? Ex.: complex(1.0, 2.0)*(double)3.0. Is 3.0 silently converted to complex, then calculated? I'm asking because I'm giving it an attempt at an eigenvalue problem and the orders can get high-ish, and as I understand it, conversions can take up a lot.
Would it be worth first declaring all doubles as complex, i.e. 3.0 -> (3.0, 0.0), or not?
I am also looking here: en.cppreference.com/w/c/language/conversion , about two pg dn, where in the example it says "...f is converted to double..." (but f is already a double), and later on, end of paragraph, "...the calculation may always be performed in a narrower type...". I'm confused.
 
@aconcernedcitizen there's not going to be a performance difference with any appreciable level of optimizations. Just benchmark it or look at the generated code if you have doubts
also, ist that std::complex or the C complex type?
 
std::compelx<double>
*complex
So then, the same applies when I write std::complex<double> a {0.0, 1.i} ?
It's just "default" initialization?
 
what even is "1.i"?
 
it's supposed to be imaginary i, defined in namespace std::numeic_literals.
*numeric
 
yeah, but shouldn't that just be
std::complex<double> a = 1.0i
then?
 
8:50 AM
I see it works just fine if I use it in usual equations: a = sqrt(2.3) + 3.2i, for example
At least gcc never complained, happily computed accurately. Was this UB?
...because I have a few other mini programs that use this kind of notation.
 
No, that should work just fine, I don't see how that would be UB
it should just be noted that by default sqrt doesn't return complex numbers if you feed in doubles/floats
 
Yes, I know. Thanks for the answers, I guess it's back to <chrono> :-)
 
I'm way too lazy to manually instrument code with <chrono> for benchmarking. There's always profiler tool that make that easier than doing it completely manually
 
 
1 hour later…
10:23 AM
ignore the above
vector<int> dp(newS + 1, 0);
does that mean vector lenght newS+1 all zeroes?
for (int j = newS; j >= nums[i]; --j) {
                dp[j] += dp[j - nums[i]];
            }
in that loop is the j decremneted first (ie so the loop starts at newS-1)?
does anyone understand the dp there?
i dont see how the j loop works and why they have used a 2d vector
 
10:42 AM
@Permian where is the "2d vector" ?
 
10:52 AM
Yeah, I don't quite get what the logic is exactly there. It looks like some form of dynamic programming, but it's not strictly memoisation I think. I don't see the arithmetic trick it uses immediately. Not sure how the mean between the sum of inputs and the target plays into it. But I guess if you step through it with a couple examples the mechanics will reveal themselves
 
 
1 hour later…
11:53 AM
yeah im going to try another haha
 
 
2 hours later…
1:59 PM
20 messages moved from Lounge<C++>
 
 
1 hour later…
3:24 PM
Anyone online yet? :)
 
nwp
Bad question. Ask your real question.
 
I want to develop a desktop application in c++ with a GUI. A user can connect to a bluetooth device, and then teh data from this device can be transferred to the application. The application process the data and sends it to the GUI which plots it. I want to use the MVC-Pattern. I know that you have a model which also includes the businesslogi i.e. class DataProcessModel. Bu I have 3 classes one for the connection one for processing the data and one for processing the plots with help of the data.
How can I combine these 3 classes to one Model?
 
3:59 PM
@SpaceToon Processing the data seems like the primary function of the model, pass in a reference to the connection (or use dependency injections as the cool kids call it). Processing for plots sounds like it should be more part of the view, depending on what kind of processing it is
or you can set up the plot data processing as something like a filter-model for the unfiltered data
 
Hey @PeterT . From the Bluetooth device I get raw data in a ByteArray. In the Class DataProcessor From these ByteArray I calculate the x,y,z-coordinates for acceleration and x,y,z-gyroscope coordiantes. Then I pass these data to two different Plots in my Plot-Class. The reason why I do not use this class in the View is because I have to setup these plots in order to real time plot my data. Therefore in my Controller I call plotData() method from my Plotter-Class
Ehat do you mean by writing pass in a reference to the connection
 
hello
 
In my BluetoothClass I pass the Data to my DataProcessing class by i.e. calling "getRawData()". And I pass my processed Data to my PlotterClass ie. my calling getFormattedData(). I do not know how to combine them to one Model maybe bny creating a 4th class named DataModel which then "communicates" with the Controller?
 
Could you help me understanding this coroutine
```
co = coroutine.create(function(value1,value2)
local tempvar3 =10
print("coroutine section1",value1,value2,tempvar3)

local tempvar1=coroutine.yield(value1+1,value2+1)
tempvar3=tempvar3+value1
print("coroutine section2",tempvar1,tempvar2,tempvar3)

local tempvar1, tempvar2=coroutine.yield(value1+value2,value1-value2)
tempvar3=tempvar3+value1
print("coroutine section3",tempvar1,tempvar2,tempvar3)
return value2,"end"
end)

print("main",coroutine.resume(co,3,2))
print("main",coroutine.resume(co,12,14))
 
@SpaceToon Yes from your description alone I can't tell whether just "wiring them up" or creating another class that coordinates them is better, just don't call that other class "Manager" :P
@Student404Mus why do you think that is C++?
 
4:11 PM
it's Lua. Isnt similar to C?
 
or rather why are you asking ~~python~~ lua questions in a c++ channel
 
lol
 
My question exactly points out how new parameters within resume function are used in coroutines to do new operations?
Because after running this the second output doesn't seem obvious as the first one.
 

« first day (1329 days earlier)      last day (1524 days later) »