|
jony neuemonic posted:ljw1004 is a Good Dude, read the post imo. it was a very good post, i am just a nervous baby c#er who does not deserve the attention of a fuckin language designer
|
# ? Jul 22, 2016 18:27 |
|
|
# ? May 25, 2024 13:49 |
|
Bloody posted:i have a discrete math problem! i have the following system: how can Bx * By = 0 given those ranges? ignoring the ranges i first note that you've got 3 equations for 4 unknowns, which means one parameter is free. i would set Bx to be anything, then By = 0, Ay = Cy * K, and then Ax = Cx * Cy / (Cy * K) = Cx / K HappyHippo fucked around with this message at 19:00 on Jul 22, 2016 |
# ? Jul 22, 2016 18:52 |
|
Oh right those ranges should start at 0
|
# ? Jul 22, 2016 18:55 |
|
Bloody posted:i have a discrete math problem! i have the following system: Bx*By cannot be 0?
|
# ? Jul 22, 2016 18:55 |
|
and define "brute force"
|
# ? Jul 22, 2016 18:56 |
|
Bloody posted:Oh right those ranges should start at 0 see my edit then
|
# ? Jul 22, 2016 18:56 |
|
Bloody posted:i have a discrete math problem! i have the following system: i started typing a bunch of stuff and thought i'd reduced this to something easier, but turns out i was probably wrong since the range constraints probably weren't being propagated properly. it's been a while since i've done this sort of stuff the Bx*By = 0 case is impossible with the given ranges, so that doesn't do anything. beyond that, if it's not possible to reduce this to a simple 2 or 3 variables with modified constraints, it might be possible to get an approximate answer that has a bounded error from the true result by reducing the discrete case as much as possible, solving for the continuous case, and then taking the closest discrete result or something honestly the first thing that comes to mind looking at this is "linear programming" but that's not quite it. unfortunately for you though, linear programming with discrete variable is NP if i recall properly i might be completely wrong about all this though, so treat this as some Terrible Programmer Opinion
|
# ? Jul 22, 2016 19:00 |
|
yeah to come at it from another way, the ideal solution is something like: Ay = Cy * K Ax = Cx / K but that runs into discretization problems: if Cx is, like, 9, then Ax needs to be 2.25, but it can't. we can work around it though by approximating it with Ax = 3 and Bx = 2 then weighting Ay and By such that the weighted average of Ax and Bx comes out to 2.25 does that make sense at all?
|
# ? Jul 22, 2016 19:09 |
|
what is your input and what are you outputting exactly? you want every solution, any solution, the "closest" solution given some values? need some more constraints on this system or something since otherwise Let K=1,Bx=By=0 => Ax = Cx, Ay = Cy and you're done HoboMan fucked around with this message at 19:27 on Jul 22, 2016 |
# ? Jul 22, 2016 19:15 |
|
K, Cx, and Cy are inputs A/B are outputs basically there's an event that lasts for some duration at some magnitude, and an offsetting event has to happen whose integral is as close to the same (opposite sign) as the first event. in trivial cases, they're equal in duration and opposite in magnitude, but some people want the duration of the offsetting event to be asymmetric
|
# ? Jul 22, 2016 19:33 |
|
i know this ruins the fun but your input space is only 2 mil, you could brute that puppy in a few min on a lovely laptop
HoboMan fucked around with this message at 19:40 on Jul 22, 2016 |
# ? Jul 22, 2016 19:37 |
|
god i really want to go back to school for math i was a math major before i dropped out but I'm insanely disorganized and can't really hack written tests when it comes to integrating tons of things somewhat complex things. like I understand what I'm supposed to do and understand the concepts but I end up forgetting steps and stuff. i had a teacher who was amazing as a professor but gave really difficult tests and I refused to take calc from anyone else so I ended up stuck in calc 3 until I dropped out of school. i'm pretty sure I'd succeed in math if I ever made it to analysis or made it into grad school or something but getting there seems to be really difficult for me.
|
# ? Jul 22, 2016 19:38 |
|
HoboMan posted:i know this ruins the fun but your input space is only 2 mil, you could brute that puppy in a few min sounds like he needs a solution relatively quickly to fire off another event this also probably means that a "good enough" answer is ok even if its not optimal
|
# ? Jul 22, 2016 19:40 |
|
i been doing that stroud's engineering math book in my freetime, on the advice of this or the other programming thread, just to be able to read papers and other work in this field
|
# ? Jul 22, 2016 19:40 |
|
Bloody posted:K, Cx, and Cy are inputs so i guess Cx and Cy are in duration and magnitude of the event, and that Ax and Ay are the same of the output? then what is Bx and By?
|
# ? Jul 22, 2016 19:41 |
|
Share Bear posted:i been doing that stroud's engineering math book in my freetime, on the advice of this or the other programming thread, just to be able to read papers and other work in this field yeah i bought that, i need to figure out how to budget stuff like that into my normal work schedule
|
# ? Jul 22, 2016 19:42 |
|
hobbesmaster posted:sounds like he needs a solution relatively quickly to fire off another event yes, but how much memory you got to work with? if you can spare it, it'd be like a 5mb table
|
# ? Jul 22, 2016 19:45 |
|
HappyHippo posted:so i guess Cx and Cy are in duration and magnitude of the event, and that Ax and Ay are the same of the output? then what is Bx and By? yeah, unless there are further constraints, it seems like you always want By = 0 and Bx = Ax
|
# ? Jul 22, 2016 19:49 |
|
|
# ? Jul 22, 2016 19:59 |
|
HoboMan posted:yeah, unless there are further constraints, it seems like you always want By = 0 and Bx = Ax that seems like it would work, since the problem is a lot simpler with 0 as being part of the valid range. the only thing that that can't solve is cases where the Cy*K term ends in .25, but there are no solutions to that regardless since none of the other term can have increments smaller than .5 anyways
|
# ? Jul 22, 2016 20:08 |
|
since when have MS compilers complained about iterators? warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' this is because the c++ standards people laughed at MS trying to get them to put in snprintf_s and stuff right. (because passing in two n's instead of one n will make sure its safe!)
|
# ? Jul 22, 2016 20:09 |
|
hobbesmaster posted:-D_SCL_SECURE_NO_WARNINGS this directive seems both oddly familiar and ominous, but i can't place it exactly... i think the warning might only come up when dealing with libraries that were compiled with different settings than the ones used in the project importing them or something? it would explain the feeling of unspecified dread i currently have if it was responsible for one of the times i had to go through a bunch of dependencies and manually recompile every single one of them to reconcile their settings with the hosed up project configuration we used at a previous job
|
# ? Jul 22, 2016 20:25 |
|
its just the iterator counterpart to _CRT_SECURE_NO_WARNINGS
|
# ? Jul 22, 2016 20:31 |
|
i must be thinking of a different thing then
|
# ? Jul 22, 2016 20:34 |
|
YeOldeButchere posted:that seems like it would work, since the problem is a lot simpler with 0 as being part of the valid range. the only thing that that can't solve is cases where the Cy*K term ends in .25, but there are no solutions to that regardless since none of the other term can have increments smaller than .5 anyways if K = 4, Cy = 20, and Cx = 10: Ay = 80 Ax = 2.5 hence the need for Bx/By: Ay = 40 Ax = 3 By = 40 Bx = 2
|
# ? Jul 22, 2016 21:05 |
|
hmm, i realize don't know how to do math anymore without both mathematica and matlab at my disposal
|
# ? Jul 22, 2016 22:20 |
|
HoboMan posted:no variable declarations! this is good i swear! no it's not confusing you see because the scope will be obvious from context! other langs like python notably also make this mistake
|
# ? Jul 22, 2016 23:54 |
|
hobbesmaster posted:(because passing in two n's instead of one n will make sure its safe!) all the _s string functions replace a single char * argument (an unbound buffer) with a pair of a char * and a size_t. think of the pair of arguments as a structure that describes a buffer, except instead of a structure you pass the fields one by one. the count argument stays because you don't necessarily want to fill the buffer (and an easy way to fill the buffer is to pass special value _TRUNCATE). conceptually speaking this is for ease of code auditing I guess, both auditing pre-_s code to easily upgrade it, and auditing _s code for correctness. you'll remember those functions came out of the massive windows xp sp2 audit, try to imagine just how much loving code they were supposed to audit and what a godsend is it to, say, look up the declaration of the buffer variable, find the buffer size declared nearby and knowing you can safely use that value blindly, without understanding what the code does. say there's a condition when count comes out larger than the buffer, because a buggy calculation that should return a smaller value than the buffer size sometimes overflows or underflows: regular snprintf would overflow the buffer and then who knows what happens next, _snprintf_s will call the invalid parameter handler and either terminate the process or return an error. C programmers hate correctness, they like to overflow buffers. I tried enabling address sanitizer on our product once, and two distinct third party libraries read beyond the end of statically declared variables, because it's "harmless". see also the linux kernel where people do range checking by comparing the addresses of two distinct arrays and the compiler goes "these two arrays don't overlap in any way I'll just delete the check" (the linker makes the arrays overlap but can't tell the compiler) std::copy is, in fact, unsafe, because the output range is unbound. this is only safe if the output is an output iterator (like say an iterator adapter over I/O, or an inserting iterator) hackbunny fucked around with this message at 00:45 on Jul 23, 2016 |
# ? Jul 23, 2016 00:26 |
|
comedyblissoption posted:you just need to look at the entire possible scope that a variable binding could be referenced every single time you use a variable! what's the big deal??? python 3's nonlocal is a delightfully succinct example of why not having variable declarations is dumb
|
# ? Jul 23, 2016 00:34 |
|
.
|
# ? Jul 23, 2016 00:37 |
|
hackbunny posted:all the _s string functions replace a single char * argument (an unbound buffer) with a pair of a char * and a size_t. think of the pair of arguments as a structure that describes a buffer, except instead of a structure you pass the fields one by one. the count argument stays because you don't necessarily want to fill the buffer. conceptually speaking none of c or c++ is safe
|
# ? Jul 23, 2016 00:45 |
|
hobbesmaster posted:none of c or c++ is safe show me the operating system not written in c or c++
|
# ? Jul 23, 2016 00:47 |
|
like, microsoft has warnings in its compiler that amount to "oh my god you're writing cross platform C or C++!" no poo poo, its a C++ compiler, you don't have to warn me that i'm compiling C++
|
# ? Jul 23, 2016 00:49 |
|
would you believe that the major objection against standardization of _s functions is that you can't prove they're more secure
|
# ? Jul 23, 2016 00:53 |
|
right because if you overrun in snprintf it'd be exactly the same in snprintf_s because you were wrong about the size of your buffer
|
# ? Jul 23, 2016 00:55 |
|
hackbunny posted:show me the operating system not written in c or c++ well, okay.
|
# ? Jul 23, 2016 01:07 |
|
hobbesmaster posted:right because if you overrun in snprintf it'd be exactly the same in snprintf_s because you were wrong about the size of your buffer see? you're one of them no, buffers don't come out of nowhere, they are allocated. take the allocation size, or the array magnitude, that's super easy to look up in the code. snprintf conflates size of the output with size of the buffer. the nearly mechanical translation from snprintf to snprintf_s consists of taking the exact value passed to malloc or whatever, and passing it as the buffer size, and leaving the string size argument unchanged. maybe it turns out you're passing the same value twice, maybe not. in the cases where it's not, you may have fixed a bug. snprintf_s is even designed so that it won't be fixed silently, it will make sure you'll notice if you hit a case that would have overflowed with the old code these are weird and silly objections, _s functions were designed for upgrading existing codebases easily, not for "elegant" code (gently caress elegant code tbh). they come from the audit of a real world project (a Goddamn operating system I might add) and this should be considered a huge plus but somehow it isn't. hey what if %n has no conceivable use outside of malicious stack corruption, you'll make it opt-in over my cold dead body
|
# ? Jul 23, 2016 01:09 |
|
|
# ? Jul 23, 2016 01:19 |
|
Bloody posted:if K = 4, Cy = 20, and Cx = 10: welp i'm an idiot the worst part of this is that i know i've seen stuff like that in undergrad, especially in the third algorithms and data structures course where a huge part of it was linear programming and other optimization problems, and how most of it is np but some can be approximated within a known bound. this totally feels like an assignment question and it pisses me off that i can't answer it!
|
# ? Jul 23, 2016 01:37 |
|
|
# ? May 25, 2024 13:49 |
|
I think the answer involves taking the floor and ceiling of Cy / K and using them as Ax and Bx and then calculating appropriate Ay and By given those Ax and Bx
|
# ? Jul 23, 2016 04:55 |