bremen_matt

1

votes
3

answer
128

views

CppAD with Eigen

I can't seem to find any great documentation on how to use Eigen with CppAD. The specific problem that I would like to see addressed is how to multiply a matrix of doubles with a matrix of CppAD::AD. Here is a MWE that does not compile: #include 'cppad/example/cppad_eigen.hpp' #include 'Eigen/Dense'...
bremen_matt
1

votes
1

answer
90

views

What does the grey dot in a box mean in GitHub GUI for Windows?

Can somebody please explain to me what the grey dot in the box means for these files? Clearly the + and - signs mean added and removed files, but I do not understand these boxes... I should also mention that these files are not empty. So I don't understand why it says 'This file is empty'.
bremen_matt
1

votes
1

answer
67

views

Tensorflow: Canonical method of diagnosing “No gradients provided for any variable…” errors

I have a high level question about how to diagnose Tensorflow errors of the form: No gradients provided for any variable, check your graph for ops that do not support gradients, between variables Of course I am interested in solving this for my specific problem, but that is not what this question is...
bremen_matt
1

votes
1

answer
159

views

Eigen: Block transpose?

I am not exactly sure how to phrase this question... I have a matrix of data that looks like this A = [ x(0,0) , ..., x(0,m-1) ] [ ... , ..., .... ] [ x(n-1,0), ..., x(n-1,m-1) ] where x is itself a vector of size p x 1. So the matrix is of size pn x m. I need a reference to the matri...
bremen_matt
1

votes
1

answer
62

views

Eigen: Efficiently storing the output of a matrix evaluation in a raw pointer

I am using some legacy C code that passing around lots of raw pointers. To interface with the code, I have to pass a function of the form: const int N = ...; T * func(T * x) { // TODO Put N elements in x return x + N; } where this function should write the result into x, and then return x. Interna...
bremen_matt
1

votes
1

answer
0

views

Javascript threading model for multiple Websockets

I have a javascript client which has to communicate with more than 1 than one Websocket server. One of these servers sends small, high frequency payloads that I can process quickly, while the other sends larger, low frequency data that takes a long time to process: this.hifreq = new WebSocket('ws:/...
bremen_matt
1

votes
1

answer
1.3k

views

--enable-static vs --disable-shared

I understand the importance of shared vs static libraries. However, several programs I have come across recommend compiling with --enable-static while other recommend --disable-shared Are these the same thing? And if not, what is the difference? If possible, please give an example of when to use...
bremen_matt
1

votes
2

answer
45

views

React shouldComponentUpdate detect change

I must be doing something dumb here, but after a day of trying to figure it out, I am turning here... I have a dropdown menu for each element of an array val which I save in the Component state: class C extends Component { state = { val : [ 1,2,3,4] } ... } where a change in each of the dropdown en...
bremen_matt
1

votes
1

answer
173

views

Lightweight GCC for Alpine

Is there a lightweight GCC distribution that I can install in Alpine? I am trying to make a small Docker image. For that reason, I am using Alpine as the base image (5MB). The standard GCC install dwarfs this in comparison (>100MB). So is there a lightweight GCC distribution that I can install on...
bremen_matt
1

votes
2

answer
42

views

Use SFINAE to enable method if tuple is large enough

I have a class that holds a tuple: template struct Point { std::tuple data; ... }; Internally, I want some methods that create views of the data. For instance, when the data has 1 or more dimension, then it is nice to have methods called x and y which pull off the first and second elements: templ...
bremen_matt
4

votes
3

answer
146

views

Specialize member functions based on size of member container

I have a class that holds some statically-sized containers: template struct Point { Container container; ... void bar(); } where a Container class might look like: struct Container1 { static constexpr size_t size = 5; } Now I want to specialize the bar method based on the size of the container. I...
bremen_matt
1

votes
0

answer
36

views

C++ Class members specified by template

Is it possible to use a variadic template to specify the members of a class? An acceptable solution would involve storing the data internally in a tuple. template struct FromPP { // TODO: Get the tuple type from parameter pack std::tuple data; // TODO: write the constructors // Other code......
bremen_matt
9

votes
3

answer
256

views

Read uint8_t from std::stringstream as a numeric type

My understanding is that reading a uint8_t from a stringstream is a problem because the stringstream will interpret the uint8_t as a char. I would like to know how I can read a uint8_t from a stringstream as a numeric type. For instance, the following code: #include #include using namespace std; i...
bremen_matt
3

votes
2

answer
100

views

C++ reverse an iterator

Is it possible to reverse an iterator in C++? For instance, a lot of algorithms are designed on the principle that you pass the beginning and ending iterators: template void func( Iterator begin, Iterator end ){ ... } Now suppose that internally, I need to iterate forward and backward over the con...
bremen_matt
1

votes
1

answer
36

views

C++: Convert vector<char> to a UTF-8 string so that I can send over a Websocket

As the title suggests, I have a raw vector of chars, and I need to encode this as a proper UTF-8 string so that I can send the result over a Websocket. My inclination was simply to do this std::vector data; // Fill data ..., then std::string utfData(data.begin(), data.end()); // Finally, send utfD...
bremen_matt
0

votes
1

answer
23

views

VSCode bad javascript formatting

I am editing some javascript files (particularly, reactjs coed) in VS Code on Ubuntu 18.04. However, the 'formatting' is really terrible. Before: import React, { Component } from 'react'; import './App.css'; import Dropzone from 'react-dropzone'; class App extends Component { render() { return ( )...
bremen_matt
2

votes
2

answer
58

views

C++11: Publisher/Consumer pattern does not finish unless publisher sleeps

In C++, I am trying to get a handle for the publisher/consumer pattern using a condition_variable. This is loosely the template I have seen online: #include #include #include #include #include #include #include using namespace std; mutex m; queue que; condition_variable cond; void write(stri...
bremen_matt
1

votes
1

answer
114

views

Python generator to list

I have a Python generator lexg which produces a list at each iteration. The code seems to work in the traditional for-loop sense, that is, for i in lexg(2,2): print(i) produces: [2, 0] [1, 1] [1, 0] [0, 2] [0, 1] [0, 0] but seems to break in list comprehension, that is, both list(lexg(2,2)) and [...
bremen_matt
4

votes
3

answer
397

views

Logging lots of Android sensor data

I have an Android application that is logging several Android sensors at approximately 100Hz. So if i am logging 10 sensors, I am writing about 3000 data points per second to a file (each sensor typically has 3 entries). Now the problem is that i want to minimize the effect of this writing on the re...
bremen_matt
3

votes
1

answer
360

views

Pure Java 8 Library module in Android Studio/Gradle Project

I have an Android Studio project with a pure Java 8 library module. Here is the complete gradle.build file for that library: apply plugin: 'java-library' dependencies { testImplementation 'junit:junit:4.12' } sourceCompatibility = '1.8' targetCompatibility = '1.8' The code is tested and works fine....
bremen_matt
1

votes
1

answer
23

views

Php: Reliable way to check if there is a query AND whether the GET argument is passed

Really new to PHP... I would like to have a PHP interface which takes day, month, and year arguments as 'd', 'm', 'y', where the default values are simply pulled from the current date. My thinking is that that should look something like this: $day = isset($_GET) && isset($_GET['d']) ? $_GET['d']...
bremen_matt
1

votes
2

answer
124

views

C++ Alias for list of template parameters

I have a lot of C++ classes that use the same list of template parameters template class A { ... }; template class B { ... }; template class C { ... }; You get the idea. Then I instantiate them like A a; B b; C c; Is there a way to somehow create an alias for this bundle of template parameters so...
bremen_matt
43

votes
7

answer
5.9k

views

Passing array to a function (and why it does not work in C++)

I have come across some C code that compiles, but I do not understand why. Specifically, I have a C library that has a lot of code using this format: void get_xu_col(int i_start, int n, double x[n], int n_x, int n_u, int n_col, double xu_col[n_col][n_x + n_u]){ ... } int main(){ ... double xu_col[n...
bremen_matt
2

votes
3

answer
88

views

Python import functions from module twice with different internal imports

I have a module lib that needs numpy. So, for instance, let's say I have a hypothetical function that looks like import numpy def doSomething(x): return numpy.sqrt(x) Now to use that function in a separate module, I will import the name as from lib import doSomething ... Here is the tricky part......
bremen_matt
5

votes
0

answer
2.4k

views

Low FPS with Camera2 API

I am experiencing a low FPS rate with the new camera2 api. Specifically, despite choosing the highest FPS range (30,30) from characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES); and setting it with mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE,...
bremen_matt
5

votes
2

answer
133

views

function return type with a different template parameter

I have some C++ classes that all have the same template parameters template struct A { }; template struct B : A{ }; template struct C : A{ }; and so on. I also have a series of methods that will work on any of these classes. However, the problem is in the return type. I would like this method to...
bremen_matt
8

votes
1

answer
202

views

Ambiguous recursive template function

In C++11, I need to call a function recursively from 0,...,n (where n is a compile time constant). This is the structure of the problem, which appears to be fatally flawed: #include 'Eigen/Dense' template struct Int { }; template constexpr X eval(const C &c, const X &x, const Int &, const Int &) { r...
bremen_matt
6

votes
2

answer
217

views

Swig -includeall except…

I have a large project where using the Swig -includeall flag seems to make sense. However, there are certain files I would not like expanded, primarily the STL libraries (e.g. vector and list). Is it possible to use the -includeall flag, but to blacklist certain files from expansion (like vector and...
bremen_matt
2

votes
1

answer
65

views

C++ Passing double array via template

I am converting some C-code to C++ so that I can use some more advanced C++ features. However, in one particular function I have a problem because the syntax is allowed in C, but not C++. Specifically, the following is valid C-code, but not C++: void get_xu_col(int i_start, int n, double x[n], int n...
bremen_matt
2

votes
1

answer
43

views

Numpy: Uniform way of retrieving `dtype`

If I have a numpy array x, I can get its data type by using dtype like this: t = x.dtype However, that obviously won't work for things like lists. I wonder if there is a standard way of retrieving types for lists and numpy arrays. In the case of lists, I guess this would mean the largest type which...
bremen_matt
6

votes
1

answer
1.3k

views

Subdomain of website for Github pages project

I have a Github project, github.com/jeti/matrix, and I set up a 'Github pages' site for the project so that it is accessible here jeti.github.io/matrix/. That is all configurable through Github. Now, I would like to add a subdomain of my personal website so that the website is accessible via the s...
bremen_matt
3

votes
1

answer
158

views

Eigen: function signature which accepts general matrix expression of fixed size and type

The Eigen documentation is filled with examples illustrating how one should write a general function accepting a matrix: template void print_cond(const MatrixBase& a) The reason to use MatrixBase as opposed to Matrix is that all dense Eigen matrix expressions derive from MatrixBase. So, for instanc...
bremen_matt
2

votes
1

answer
31

views

How can I get a reference to an element in list using key?

A simple question which I can't find a good answer to. I have a very large list of items (>1000, possibly greater than 10k). Each of these has a unique key. Is it possible to get a ref to an element by only knowing its key? I can certainly generate refs myself, but this would require me maintainin...
bremen_matt
1

votes
2

answer
78

views

Eigen: Efficient way of referencing ArrayWrapper

I am interfacing some code with raw pointers. So I have extensive use of the map class: void foo(T* raw_pointer){ const int rows = ...; const int cols = ...; Map mat(raw_pointer); // DO some stuff with 'mat' } Now I want to apply some cwise operations in foo, which I accomplish using .array(). The c...
bremen_matt
10

votes
1

answer
2k

views

Overhead of `using`

For my problem, I can use the using directive in two ways. They basically boil down to these options: template struct A { private: // Define our types using WrapperType = Wrapper; public: U *operator()(U *g) const { // TODO: use WrapperType } }; OR: struct B { template U *operator()(U *g) con...
bremen_matt
2

votes
1

answer
987

views

Multiple sequential Tensorflow operations in same Session.run() call

As the title suggests, I want to run multiple Tensorflow operations in the same Session.run() call. Specifically, to make the problem more concrete, suppose I want to run multiple training iterations in a single call. The standard way of doing that with multiple Session.run() calls would be somethi...
bremen_matt
3

votes
0

answer
58

views

Register a custom camera source with the Camera API

I have quite a bit of experience with the camera API, but I could not find any documentation to answer this question... Most phones already have a front and a back camera. Would it be possible to simulate a 3rd camera via software (probably using a service), and register that with the api? The idea...
bremen_matt
2

votes
2

answer
308

views

Eigen: Divide each row by last row

I can't quite figure out the syntax for this when using Eigen's rowwise operations... I have an Eigen matrix, and I want to divide each row by the last row. So if we started with a matrix r = [ 0, 1 2, 3 4, 5 ] then after this transform, I want to have r = [ 0, .2 .5, .6 1, 1 ] Preferably the o...
bremen_matt
4

votes
1

answer
99

views

C++ constexpr for polynomial evaluation with Horner's method

I have want to be able go evaluate the derivative of a polynomial using Horner's method and use the result as a constexpr. This seems incredibly mundane, but I am missing something obvious because the compiler says that I am exceeding maximum recursion depth. The core recursion happens here: templat...
bremen_matt
5

votes
1

answer
353

views

Eigen: Return a reference to a block of a matrix with compile-time dimension checks

What I am asking is a generalization of this question. Specifically, I would like to make a C++ Eigen wrapper around a legacy C and Fortran library, which uses a 2D data-structure: [ x[0,0] ... x[0,w-1] ] [ u[0,0] ... u[0,w-1] ] [ ... ] [ x[c-1,0] ... x[c-1,w-1] ] [ u[c-...
bremen_matt

View additional