mat | R demo package illustrating BLAS and LAPACK calls
kandi X-RAY | mat Summary
kandi X-RAY | mat Summary
this is an r package that is a demo for statistical confusing classes about how to call blas and lapack routines to do numerical linear algebra in c code called from r. the name of the git repo is different from the name of the r package because the package used to be called mat and was renamed baz to avoid a conflict with cran, not that we intend to put the package on cran but r cmd check --as-cran does more checks, so we want to pass that too. it is just a demo, it doesn't show how to use all blas and linpack routines (only a few of them, but if you can figure out how to call one, then you can figure out how to call the rest). thus all the interesting stuff in this package is in the src directory of the package, which contains the files. everything else is just junk that surrounds this with an r package so it can get exercised. the examples in the help pages and in the tests directory of the package show that the code works. if the package is checked with. valgrind does not complain. (actually, by default, it complains a lot, but all of the complaints are about c function wcsrtombs, which is not in our code, not even in the code of r, but in the c standard
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mat
mat Key Features
mat Examples and Code Snippets
Community Discussions
Trending Discussions on mat
QUESTION
I inherited an application with opencv, shiboken and pyside and my first task was to update to qt6, pyside6 and opencv 4.5.5. This has gone well so far, I can import the module and make class instances etc. However I have a crash when passing numpy arrays:
I am passing images in the form of numpy arrays through python to opencv and I am using pyopencv_to
to convert from the array to cv::Mat
. This worked in a previous version of opencv (4.5.3), but with 4.5.5 it seems to be broken.
When I try to pass an array through pyopencv_to
, I get the exception opencv_ARRAY_API was nullptr
. My predecessor solved this by directly calling PyInit_cv2()
, which was apparently previously included via a header. But I cannot find any header in the git under the tag 4.5.3 that defines this function. Is this a file that is generated? I can see there is a pycompat.hpp
, but that does not include the function either.
Is there a canonical way to initialize everything so that numpy arrays can be passed properly? Or a tutorial anyone can point me to? My searches have so far not produced any useful hints.
Thanks a lot in advance! :)
...ANSWER
Answered 2022-Apr-05 at 12:36I finally found a solution. I dont know if this is the correct way of doing it, but it works.
I made a header file that contains
QUESTION
I am trying to read a large matrix into R. The matrix has dimensionality: 3'987'288 x 93 and is about 3GB large. (Class = double) It is saved as a .mat file (it is not a v7.3 .mat file)
I tried to read the matrix with the R.matlab package:
...ANSWER
Answered 2022-Mar-20 at 01:38Apparently V7.3 is not the only incompatible mat file version. As stated in the RDocuments,
readMat: Reads a MAT file structure from a connection or a file Description
Reads a MAT file structure from a connection or a file. Both the MAT version 4 and MAT version 5 file formats are supported.
And long story short, version 4 and version 5 cannot save such large dataset in one file. I think at least 2 solutions are straight forward:
Exchange data in a different file format, e.g. HDF5 or SQlite. Such files are well supported both in R and matlab and do not have the compatibility issue.
Save mat file in matlab in version 4 with the '-v4' switch, but there is an upper size limit in version 4, so you'll likely need to split you data across multiple files.
QUESTION
I have this example matrix and I want to change the entries of the matrix with "YES"
or "NO"
based on a conditional if
statement.
ANSWER
Answered 2021-Sep-04 at 15:25You do not need loops here. Just use the whole matrix in your call to x>5
QUESTION
I'm trying to compute average values of shifted diagonals of a square array.
Given input matrix like (in reality much larger than 3x3):
...ANSWER
Answered 2022-Mar-05 at 16:03The tricky part is summing the diagonals. I've questioned multiple times in the past about the fastest approach to accomplish this.
One solution is to use bincount
:
QUESTION
mat <- diag(3)
> mat
[,1] [,2] [,3]
[1,] 1 0 0
[2,] 0 1 0
[3,] 0 0 1
...ANSWER
Answered 2021-Dec-27 at 18:53Use replace
QUESTION
I have created a working CNN model in Keras/Tensorflow, and have successfully used the CIFAR-10 & MNIST datasets to test this model. The functioning code as seen below:
...ANSWER
Answered 2021-Dec-16 at 10:18If the hyperspectral dataset is given to you as a large image with many channels, I suppose that the classification of each pixel should depend on the pixels around it (otherwise I would not format the data as an image, i.e. without grid structure). Given this assumption, breaking up the input picture into 1x1 parts is not a good idea as you are loosing the grid structure.
I further suppose that the order of the channels is arbitrary, which implies that convolution over the channels is probably not meaningful (which you however did not plan to do anyways).
Instead of reformatting the data the way you did, you may want to create a model that takes an image as input and also outputs an "image" containing the classifications for each pixel. I.e. if you have 10 classes and take a (145, 145, 200) image as input, your model would output a (145, 145, 10) image. In that architecture you would not have any fully-connected layers. Your output layer would also be a convolutional layer.
That however means that you will not be able to keep your current architecture. That is because the tasks for MNIST/CIFAR10 and your hyperspectral dataset are not the same. For MNIST/CIFAR10 you want to classify an image in it's entirety, while for the other dataset you want to assign a class to each pixel (while most likely also using the pixels around each pixel).
Some further ideas:
- If you want to turn the pixel classification task on the hyperspectral dataset into a classification task for an entire image, maybe you can reformulate that task as "classifying a hyperspectral image as the class of it's center (or top-left, or bottom-right, or (21th, 104th), or whatever) pixel". To obtain the data from your single hyperspectral image, for each pixel, I would shift the image such that the target pixel is at the desired location (e.g. the center). All pixels that "fall off" the border could be inserted at the other side of the image.
- If you want to stick with a pixel classification task but need more data, maybe split up the single hyperspectral image you have into many smaller images (e.g. 10x10x200). You may even want to use images of many different sizes. If you model only has convolution and pooling layers and you make sure to maintain the sizes of the image, that should work out.
QUESTION
In this programming problem, the input is an n
×m
integer matrix. Typically, n
≈ 105 and m
≈ 10. The official solution (1606D, Tutorial) is quite imperative: it involves some matrix manipulation, precomputation and aggregation. For fun, I took it as an STUArray implementation exercise.
I have managed to implement it using STUArray, but still the program takes way more memory than permitted (256MB). Even when run locally, the maximum resident set size is >400 MB. On profiling, reading from stdin seems to be dominating the memory footprint:
Functions readv
and readv.readInt
, responsible for parsing integers and saving them into a 2D list, are taking around 50-70 MB, as opposed to around 16 MB = (106 integers) × (8 bytes per integer + 8 bytes per link).
Is there a hope I can get the total memory below 256 MB? I'm already using Text
package for input. Maybe I should avoid lists altogether and directly read integers from stdin to the array. How can we do that? Or, is the issue elsewhere?
ANSWER
Answered 2021-Dec-05 at 11:40Contrary to common belief Haskell is quite friendly with respect to problems like that. The real issue is that the array
library that comes with GHC is total garbage. Another big problem is that everyone is taught in Haskell to use lists where arrays should be used instead, which is usually one of the major sources of slow code and memory bloated programs. So, it is not surprising that GC takes a long time, it is because there is way too much stuff being allocation. Here is a run on the supplied input for the solution provided below:
QUESTION
Why does knn always predict the same number? How can I solve this? The dataset is here.
Code:
...ANSWER
Answered 2021-Oct-17 at 07:36TL;DR
It have to do with the StandardScaler
, change it to a simple normalisation.
e.g.
QUESTION
I am using angular material for all my controls. We have a requirement to disable auto-complete so that any previously typed value will not show up. I have my code as below. I tried autocomplete "off" "disabled" and other suggestions that I found online. But nothing seems to work.
...ANSWER
Answered 2021-Sep-15 at 22:48In the past, many developers would add autocomplete="off"
to their form fields to prevent the browser from performing any kind of autocomplete functionality. While Chrome will still respect this tag for autocomplete data, it will not respect it for autofill data.
One workaround is to put an unknown value in the autocomplete,
.
When testing this it worked for me most of the time, but for some reason didn't work anymore afterwards.
My advise is not to fight against it and use it's potential by properly using the autocomplete attribute as explained here.
QUESTION
I added a few CSS properties to different mat-buttons on my Angular 12 based website. In order to not accidentally apply these properties to all mat-buttons, but only to the ones I want to apply them to, I added a class to the buttons and used it to set the CSS properties like this:
Component html file:
...ANSWER
Answered 2021-Sep-17 at 14:31Those styles are rewritten. Use !important
:
styles.scss
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mat
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page