storage format using SPARSE and INT8

1 visualizzazione (ultimi 30 giorni)
Giovanni Gardan
Giovanni Gardan il 27 Mag 2020
I'd like to save storage and time when I run my code. In order to do this I'm trying to modify the format-storage of some (1 0 -1) matrixes and in the follow example I note that int8 is the best. That's ok!
But if I try to save B as a sparse matrix (see the comment) I get the following error:
Undefined function 'sparse' for input arguments of type 'int8'.
1) So, is it possible to save a sparse matrix (made only with the values of element 1, 0 or -1) not with double precision, but with int storage-format to save too much storage?
2) In general, does making operation between different saved elements (for example the sum of matrix B with another matrix, but saved in double precision) create problems??
%Code.m
A = [1 0 0 0 0 0 0 0 0 0 0 0 0;
-1 0 0 0 0 0 0 0 0 0 0 0 1;
0 0 0 0 0 0 0 0 0 1 0 0 0];
B= int8(A);
C = sparse(A);
% D=sparse(B) <<<<<<<<<HERE THE COMMENT
whos A B C
-------------------------------------------------------------------------------------------------
%Command window shows
>> Code
Name Size Bytes Class Attributes
A 3x13 312 double
B 3x13 39 int8
C 3x13 176 double sparse

Risposte (0)

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by