Posts

Why is the GNU scientific library matrix multiplication slower than numpy.matmul?

12 2 Why is it that the matrix multiplication with Numpy is much faster than gsl_blas_sgemm from GSL, for instance: import numpy as np import time N = 1000 M = np.zeros(shape=(N, N), dtype=np.float) for i in range(N): for j in range(N): M[i, j] = 0.23 + 100*i + j tic = time.time() np.matmul(M, M) toc = time.time() print(toc - tic) gives something between 0.017 - 0.019 seconds, while in C++: #include <chrono> #include <iostream> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> using namespace std::chrono; int main(void) { int N = 1000; gsl_matrix_float* M = gsl_matrix_float_alloc(N, N); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { gsl_matrix_float_set(M, i, j, 0.23 ...

Bootstrap v5 modal show issue

2 2 I decided to go ahead and update my site to the latest version of Bootstrap, version 5.0 and am having difficulty getting modals to work. Reading the migration guide said nothing about breaking modals and my site worked perfectly before. My code uses javascript/jQuery to fire off the modal after the ajax loads the text. The ajax part still works fine, but it's not firing the modal after it retrieves it. I'm using the latest bootstrap.bundle.min.js. $( document ).ready(function() { $('.hourModal').click(function(){ var obj_id = $(this).data('id'); $.ajax({ url: 'ajax-multi.php', type: 'POST', data: {obj_id: obj_id,role:'some_role'}, //dataType: 'html', success...

Android Studio Gradle: Please remove usages of `jcenter()` Maven repository from your build scripts / JCenter is at end of life

9 3 In Android Studio 4.2 there is a warning: buildscript { ext.kotlin_version = '1.5.0' repositories { google() jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:4.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { google() jcenter() mavenCentral() } } If I remove jcenter() then it can't find some dependencies of my app project: > Could not find org.koin:koin-core:2.0.1. Required by: project :app > Could not find org.koin:koin-androidx-scope:2.0.1. Required by: project :app > Could not find org.koin:koin-and...

Update state within listener that is inside useEffect

7 2 I have a hook called useQueryEvents that 1) fetches all past transactions for a user and 2) listens to the network for incoming/outgoing transactions. In both cases the transactions are passed into a function addActionToActivity that simply appends it to the activity array and updates it in the context state under the key activity . I can't get the activity to sync correctly. Whenever the state updates it does not have the last transaction because it's always one step behind. If I add activity to the dependancy it works but then starts a new listener (due to the whole function being called again with the new activity value) which causes an infinity-like-loop which keeps switching up the state. function useQueryEvents() { const { state: { connectedNet...

What is the most efficient way of getting the intersection of k sorted arrays?

6 2 Given k sorted arrays what is the most efficient way of getting the intersection of these lists Ex INPUT: [[1,3,5,7], [1,1,3,5,7], [1,4,7,9]] Output: [1,7] There is a way to get the union of k sorted arrays based on what I read in the Elements of programming interviews book in nlogk time. I was wondering if there is a way to do something similar for the intersection as well ## merge sorted arrays in nlogk time [ regular appending and merging is nlogn time ] import heapq def mergeArys(srtd_arys): heap = [] srtd_iters = [iter(x) for x in srtd_arys] # put the first element from each srtd array onto the heap for idx, it in enumerate(srtd_iters): elem = next(it, None) if elem: heapq.heappush(heap, (elem, idx)) ...

Why am I getting AbstractDynamicObject$CustomMessageMissingMethodException error?

41 3 I have just started a new project and am trying to connect to Firebase. As soon as I try to build my project I got the error : Could not parse the Android application Module's Gradle Config, so I looked in my build which told me that jCenter() was deprecated and that I should remove it. When I removed it, everything worked fine. However, when I tried to connect to Firebase I got the error: AbstractDynamicObject$CustomMessageMissingMethodException. What may be causing this? Full stack trace: Caused by: java.lang.RuntimeException: com.android.build.gradle.internal.crash.ExternalApiUsageException: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method setVariantDir() for arguments [debug] on task ...

How *(&arr + 1) - arr is working to give the array size [duplicate]

32 5 This question already has answers here : How does *(&arr + 1) - arr give the length in elements of array arr? (3 answers) Why are the values different? C++ pointer (2 answers) Closed 3 days ago . int arr[] = { 3, 5, 9, 2...