storage format using SPARSE and INT8

조회 수: 1 (최근 30일)
Giovanni Gardan
Giovanni Gardan 2020년 5월 27일
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by