|
No Gravitas posted:import performance is pretty darn slow Do you understand what transactions are, what autocommit is, and why it will kill your SQLite performance?
|
# ? Aug 4, 2014 09:45 |
|
|
# ? Jun 8, 2024 07:17 |
|
No Gravitas posted:poo poo supervisor, poo poo budget, poo poo skills, poo poo politics and poo poo requirements. This is all a given considering academia but what is the actual technical problem you are attempting to solve. I feel there is a very good chance of an X/Y issue here so taking a step back to analyze what's actually going on is important. SQLite is a very powerful tool and casting it aside is a very strong indicator that something's very wrong.
|
# ? Aug 4, 2014 09:48 |
|
I've been working with templates, and have a few questions: Is there a better way to work around the enclosing scope limit for objects captured by reference than what I am doing? Also, is there a way to capture the object pointed to by a variable by reference? I know creating a reference to a pointer object sounds weird, but currently I have lamdas shared between many functions which are setup for capture by reference which I don't want to duplicate for capturing the pointer by value. For example code:
code:
|
# ? Aug 4, 2014 13:27 |
|
How exactly does using the Android NDK to run C++ code on an Android device work? I thought it would just allow me to run a C++ program but reading about it seems like it's just used for running snippets and requires mainly Java code anyway, which left me thinking it would probably be really slow. Have I missed the point of it? Do you really need to code Android games in Java?
|
# ? Aug 4, 2014 14:37 |
|
Praseodymi posted:How exactly does using the Android NDK to run C++ code on an Android device work? I thought it would just allow me to run a C++ program but reading about it seems like it's just used for running snippets and requires mainly Java code anyway, which left me thinking it would probably be really slow. Have I missed the point of it? Do you really need to code Android games in Java? You need a Java UI to interact with the user, because all of Android's UI system is in Java. That said, that Java UI doesn't need to do much more than throw up a Surface to draw upon and then pass that Surface back to C++. Because you probably don't want your game to suck, you'll have to deal with a bunch more things in the Java code (like onPause/onResume at least), but that's the gist of it. Technically you can also use the NDK to crosscompile pure console applications.
|
# ? Aug 4, 2014 14:42 |
|
So you only have to use Java for stuff that's unique to the device? Cool, how does SDL's touchscreen stuff work? Or is that actually for PC touch devices and still requires some abstraction for Android?
|
# ? Aug 4, 2014 14:57 |
|
Praseodymi posted:So you only have to use Java for stuff that's unique to the device? For stuff that's unique to Android. quote:Cool, how does SDL's touchscreen stuff work? Or is that actually for PC touch devices and still requires some abstraction for Android? It almost certainly contains a small Java shim that sends all the input events to native code. FWIW: http://hg.libsdl.org/SDL/file/704a0bfecf75/README-android.txt (which unsurprisingly also has a part about dealing with onPause/onResume)
|
# ? Aug 4, 2014 15:08 |
|
Praseodymi posted:How exactly does using the Android NDK to run C++ code on an Android device work? I thought it would just allow me to run a C++ program but reading about it seems like it's just used for running snippets and requires mainly Java code anyway, which left me thinking it would probably be really slow. Have I missed the point of it? Do you really need to code Android games in Java? You can code android games with various levels of Java depending on how much you want to rely on the first party APIs. The two you should look at are OpenGLActivity where you get a surface and a callback once per tick, and NativeActivity where you never see Java directly and even touch events come into the JNI interface.
|
# ? Aug 4, 2014 15:29 |
|
Praseodymi posted:How exactly does using the Android NDK to run C++ code on an Android device work? I thought it would just allow me to run a C++ program but reading about it seems like it's just used for running snippets and requires mainly Java code anyway, which left me thinking it would probably be really slow. Have I missed the point of it? Do you really need to code Android games in Java? The NDK is horrible to work with, especially when you want to debug, and especially if you're not already familiar with Android's semantics. Write your stuff in Java and optimize it there; if you hit an actual case where you can't get acceptable performance, then consider narrowly using the NDK.
|
# ? Aug 4, 2014 15:46 |
|
Ika posted:I've been working with templates, and have a few questions: Is there a better way to work around the enclosing scope limit for objects captured by reference than what I am doing? Unless I'm mistaken, you just need to put this in the capture list, and then you can refer to the member variables directly.
|
# ? Aug 4, 2014 15:49 |
|
seiken posted:Unless I'm mistaken, you just need to put this in the capture list, and then you can refer to the member variables directly. Yes, but I'm trying to avoid that, because the lambda is defined in a shared macro and the class it operates on sometimes is a member variable and sometimes is on the stack or a function parameter. We can't modify the class itself for reasons. I'm not exactly sure why it is in a macrod lambda and not a static template function, it may have been to avoid multiple definitions of the same template function in a global unit. Ika fucked around with this message at 16:52 on Aug 4, 2014 |
# ? Aug 4, 2014 16:50 |
|
Subjunctive posted:The NDK is horrible to work with, especially when you want to debug, and especially if you're not already familiar with Android's semantics. Write your stuff in Java and optimize it there; if you hit an actual case where you can't get acceptable performance, then consider narrowly using the NDK. This is great advice if your only concern is Android, but if you need multiplatform support then you will have to suck it up and live in the hell that is NDK. Or write your stuff twice - which honestly, if it is a small code base may be preferable to using the NDK - it's that bad.
|
# ? Aug 4, 2014 17:01 |
|
Ika posted:Yes, but I'm trying to avoid that, because the lambda is defined in a shared macro and the class it operates on sometimes is a member variable and sometimes is on the stack or a function parameter. We can't modify the class itself for reasons. I'm not exactly sure why it is in a macrod lambda and not a static template function, it may have been to avoid multiple definitions of the same template function in a global unit. You're going to need to post your actual code then because this is a completely different situation from the code in the original question. Can't you capture bar where bar is the member variable/stack variable/function parameter and access bar->foo inside the lambda? Edit: if the problem is the distinction between dereferencing/not-dereferencing the thing you want to capture, then you could define a template like C++ code:
seiken fucked around with this message at 17:24 on Aug 4, 2014 |
# ? Aug 4, 2014 17:14 |
|
I'm writing a program to solve for the elements of a translation matrix given two sets of associated (X, Y, Z) measurements. This problem naturally takes the form: p_(frame 1)_i = T_(frame_1)_(frame_0)*p(frame_0)_i Where T is a homogenous matrix and p is a point of the form transpose([x, y, z, 1]) You can then form a linear system and solve for the 12 rotational/translational elements of T. This is just overconstrained linear least squares, so it can be solved with any gradient descent or Cholesky factorization, but it also comes with the implicit constraint that sqrt(T_i_1^2 + T_i_2^2 + T_i_3^2) = 1 for i = 1, 2, 3. However, that makes the problem nonlinear. My questions are: 1. Is it worth it to model the sqrt(T_i_1^2 + T_i_2^2 + T_i_3^2) = 1 for i = 1, 2, 3 constraint, given that it makes the problem nonlinear and I often get working results anyway? 2. If it is, what is the best open source C/C++ tool for modeling such things that you have come across? 3. I'm currently trying to use Ceres-solver (and running into a couple problems) with a cost function of the form: residual = ||(Ax-b)*(1/covariances matrix)|| + abs(sqrt(T_11^2 + T_12^2 + T12^2)-1)*1/covariance + abs(sqrt(T_21^2 + T_22^2 + T_22^2)-1)*1/covariance + abs(sqrt(T_31^2 + T_32^2 + T32^2)-1)*1/covariance with the covariance on the unit row constraints being relatively high. Does anyone see any issues with this model?
|
# ? Aug 4, 2014 18:54 |
|
Is there a way to call functions at an address including passing arguments without having to write a function prototype for each one?
|
# ? Aug 4, 2014 19:53 |
|
PS. Love the cabin posted:Is there a way to call functions at an address including passing arguments without having to write a function prototype for each one? Write an assembly stub to stick your arguments in the proper place for your calling convention. This requires you to know what the function prototype is.
|
# ? Aug 4, 2014 19:58 |
|
PS. Love the cabin posted:Is there a way to call functions at an address including passing arguments without having to write a function prototype for each one? As b0lt said, yes, but the alternative is worse. You can use typedefs to make it less of a hassle though. code:
|
# ? Aug 4, 2014 20:36 |
|
seiken posted:You're going to need to post your actual code then because this is a completely different situation from the code in the original question. Can't you capture bar where bar is the member variable/stack variable/function parameter and access bar->foo inside the lambda? I can't capture bar if it is a member variable, the compiler throws an error and wants me to capture this instead, which I can't do because the same macro/lambda is also used to manipulate stack variables. If there actually is a way of capturing this->foo by reference or &this->foo by value without capturing this it would solve most of my problem. I can't call my macro with &foo, *foo, std::addressof(foo) etc because that ends up being replaced in the capture expression, so currently I use foo as an additional parameter to the lambda function and have to use the exact type of foo in the macro so it can be expanded into a lambda with the correct parameter type in the definition. The alternative is using a temp variable to move foo into the local scope and then capturing it, then I need a temp variable but can capture it instead of using a parameter. seiken posted:Edit: if the problem is the distinction between dereferencing/not-dereferencing the thing you want to capture, then you could define a template like I was hoping there was a some special syntax which would allow me to capture the result of std::addressof(foo) etc without using an explicit temp variable to hold the value. So basically C++ code:
|
# ? Aug 4, 2014 22:52 |
|
Ika posted:I was hoping there was a some special syntax which would allow me to capture the result of std::addressof(foo) etc without using an explicit temp variable to hold the value. So basically uh if you have the foo symbol why not C++ code:
|
# ? Aug 4, 2014 23:04 |
|
Dren posted:uh Because the lambda is in a macro and the variable isn't always called foo nor is it always a pointer. Don't have the code here but a really simple case would be: C++ code:
Right now the code uses C++ code:
Ika fucked around with this message at 00:02 on Aug 5, 2014 |
# ? Aug 4, 2014 23:59 |
|
Edison was a dick posted:As b0lt said, yes, but the alternative is worse. I'm not sure I ever have, or will see another example as beautiful. Thanks Looks like I'll just typedef every function then, me doing stuff with assembly is a recipe for disaster.
|
# ? Aug 5, 2014 00:53 |
|
Ika try doing a lambda inside a std::bind. Should create a copy of a member var or stack var that is captured by the lambda.
|
# ? Aug 5, 2014 02:14 |
|
Ika posted:Because the lambda is in a macro and the variable isn't always called foo nor is it always a pointer. Don't have the code here but a really simple case would be: Nothing you've said prevents default-capture from working. If you have some expression which you can access in a scope, then you can access it via exactly the same expression inside a lambda with a capture-list of [&] (default reference capture - you don't need to specify any name). Try this and if it doesn't work post a complete minimal example which exhibits the problem instead of vague comments
|
# ? Aug 5, 2014 02:16 |
|
The Gay Bean posted:math This is actually a super interesting question but might be out of the scope of this thread. For what it's worth - I'm certain that fitting an affine transform to a dataset has been done before, but without doing any research, you might try a hybrid approach? I.e., use least squares to get an initial solution, then toss that initial solution into a local nonlinear optimizer like Levenberg-Marquardt (Ceres has this actually) where you use your constraint as your objective function. This is fun to think about but my idea's probably horrible and this is definitely a derail so I'll stop here.
|
# ? Aug 5, 2014 05:51 |
|
Is there any way to get gdb to know about macro definitions when I'm compiling with clang? I know I can use -ggdb -g3 with gcc but I would like to use clang if possible. With clang-3.3 using -g3 doesn't do anything different than just -g, and there's no macro information for gdb.
|
# ? Aug 11, 2014 17:13 |
|
PS. Love the cabin posted:Is there a way to call functions at an address including passing arguments without having to write a function prototype for each one? You know how C/C++ lets you shoot yourself in the foot with extreme ease? This library lets you do it with a bazooka. Caveat emptor.
|
# ? Aug 11, 2014 17:23 |
|
Happy I found this section, I have homework I am trying to do and I feel pretty lost. It's a class all about C and I seem to be stuck in a loop, I never have this issue with vb.net so I need help if possible. I'm supposed to come up with a way to push grades into an array, pop them out, display the array, show the grade average and exit. Right now I can send "p" and it will ask me to enter the letter grade. But it just then keeps asking me for the letter. If i put a break after setting the array to the grade they entered then it closes the whole script. I want it to loop again asking to scanf for a new &z value so I can hit that against the if's. Any help would be awesome... this was due last night but I hope to get some credit. I hate C so far. int main() { int x; int y; char z; char grade; int array[8][1]; printf("Send: p for Push\n"); printf("pop for Pop\n"); printf("d for Display\n"); printf("a for Average\n"); printf("x for Exit\n"); for ( x = 0; x < 8; x++ ) { //z = " "; scanf("%c", &z); if (z="p"){ printf("Enter letter grade. (A/B/C/D/F)\n"); scanf("%c", &grade); array[x][1] == &grade; } else if (z="d"){ printf( "Array Indices:\n" ); for ( x = 0; x < 8;x++ ) { printf( "%d. %d\n", x, array[x][1] ); } break; } } getchar(); }
|
# ? Aug 11, 2014 20:01 |
|
1. use [code] tags so your code gets formatted correctly when you paste it otherwise it is an unreadable mess 2. You should double check what the difference between '=' and '==' is 3. You don't need a 2 dimensional array for what you are doing 4. We aren't going to do your homework for you
|
# ? Aug 11, 2014 20:10 |
|
TomTrustworthy posted:
For starters, you want if (z=='p') there: two =s, and single quotes for characters. I have no idea why you're putting the address of z into the array like that either. What are you trying to do there? But your compiler should be screaming about a bunch of these things -- are you checking the warnings?
|
# ? Aug 11, 2014 20:11 |
|
Without even getting into the semantics of your program: 1. Use [code language="C"] tags. 2. You seem to have = and == mixed up. 3. You are confusing individual characters, delimited with single-quotes, with strings of length 1, delimited with double-quotes (e.g. if (z="p"). VB.NET will let you be a little less precise about this sort of thing, but C will not. 4. There's no reason for array to be two-dimensional, especially when the second dimension isn't really another dimension. Just declare it as array[8] and don't use a second set of subscripts anywhere. Semantic troubleshooting is going to be a whole other kettle of fish - your code is bordering on Not Even Wrong territory. Since you said you're proficient in VB.NET, it might be worthwhile to write the program in that language first so that you can get a clear sense of which problems are logic problems and which are language problems.
|
# ? Aug 11, 2014 20:13 |
|
Thanks guys I will try to fix the issues you pointed out.
|
# ? Aug 11, 2014 20:38 |
|
code:
|
# ? Aug 12, 2014 23:17 |
|
Postincrement evaluates to the variable's old value. That's the difference between preincrement and postincrement.
|
# ? Aug 12, 2014 23:20 |
|
Ok, so I'm merely retarded. Carry on. I guess I may as well ask if it's true that there's a potentially meaningful performance difference between ++i and i++ in a for loop, if it's not optimized away at least.
|
# ? Aug 12, 2014 23:26 |
|
eXXon posted:Ok, so I'm merely retarded. Carry on. If i is an integer or something, then no. If i is a C++ class with some fancy overloaded operator++, then ++i may be faster.
|
# ? Aug 12, 2014 23:31 |
|
I had a dumb moment myself rearranging some code to have a local variable be global and wondering why later on it would all of the sudden be NULL. As it turns out I forgot to remove the local declaration from one function so it was declared a second time and initialized to NULL. Is that actually allowed or is it just a compiler bug?
|
# ? Aug 13, 2014 04:48 |
|
(a) You should have loving renamed it and grepped so that you knew there weren't any instances of the old variable name. (b) You shouldn't have made it a global in the first place, you're doing something completely moronic.
|
# ? Aug 13, 2014 04:50 |
|
Relax, I'm just loving around after not doing anything in years.
|
# ? Aug 13, 2014 04:53 |
|
PS. Love the cabin posted:Is that actually allowed or is it just a compiler bug?
|
# ? Aug 13, 2014 05:14 |
|
|
# ? Jun 8, 2024 07:17 |
|
That explains it perfectly, thanks! I've never actually encountered that until random fuckery and chance aligned.
|
# ? Aug 13, 2014 05:17 |