sparse matrix format
see Spare Matrix wikipedia item,
and scipy's documentation on different choices of sparse matrix type
sparse matrix storage, only store non-zero entries. there're multiple possible data structures for this, and can be divided into 2 groups
- support efficient modification
- DOK (dictory of keys)
- LIL (list of lists)
- COO (coordiate list)
- support efficient access
- CSR/CSC (compressed sparse row/column)
Dictionary of Keys (DOK)
- a dictionary that maps (row, col)-pair to the value;
- good for incremental build;
- poor for iterating;
- often used for building matrix, and convert to another format
List of Lists (LIL)
- matrix is a list of lists, one list for each row;
- each row list stores the (col, val) pair list;
- efficient for creation/insertion
Coordinate List (COO) aka IJV format
- sotre a list of (row, col, value) triplets, and ideally sorted by row then col;
- also known as IJV or Triplet format.
Compressed Sparse Row (CSR)
- an m*n matrix is represented as 3 vectors:
vals
,row_ptr
,col_idx
; vals
: all values in row-major; length is number of non-zero matrix elements;col_idx
: all values' column index in row-major order; same length with vals;row_ptr
:row_ptr[0] = 0
,row_ptr[k] = number-of-vals in first k rows
; i.e.row_ptr[k+1]-row_ptr[k]
is number of elements at row k;- this is extremely optimized for row-by-row iteration: only access current portion of vals and col_idx, and 2 elements of row_ptr to determine the portion - super cache friendly;
- thus very suitable for cases like matrix-multiplication, matrix-vector-multiplication;
sparse matrix format的更多相关文章
- 理解Compressed Sparse Column Format (CSC)
最近在看<Spark for Data Science>这本书,阅读到<Machine Learning>这一节的时候被稀疏矩阵的存储格式CSC给弄的晕头转向的.所以专门写一篇 ...
- sparse matrix
w https://en.wikipedia.org/wiki/Sparse_matrix 稀疏矩阵存储格式总结+存储效率对比:COO,CSR,DIA,ELL,HYB - Bin的专栏 - 博客园ht ...
- 311. Sparse Matrix Multiplication
题目: Given two sparse matrices A and B, return the result of AB. You may assume that A's column numbe ...
- 用R的dgCMatrix包来构建稀疏矩阵 | sparse matrix by dgCMatrix
sparse matrix是用来存储大型稀疏矩阵用得,单细胞表达数据基本都用这个格式来存储,因为单细胞很大部分都是0,用普通文本矩阵存储太占空间. 使用也是相当简单: library("Ma ...
- [leetcode]311. Sparse Matrix Multiplication 稀疏矩阵相乘
Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is ...
- 稀疏矩阵乘法 · Sparse Matrix Multiplication
[抄题]: 给定两个 稀疏矩阵 A 和 B,返回AB的结果.您可以假设A的列数等于B的行数. [暴力解法]: 时间分析: 空间分析: [思维问题]: [一句话思路]: 如果为零则不相乘,优化常数的复杂 ...
- Sparse Matrix Multiplication
Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is ...
- [LeetCode] Sparse Matrix Multiplication 稀疏矩阵相乘
Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is ...
- [LeetCode] Sparse Matrix Multiplication
Problem Description: Given two sparse matrices A and B, return the result of AB. You may assume that ...
随机推荐
- Easy AR简单教程
Easy AR简单教程 相关SDK资源下载链接:http://pan.baidu.com/s/1dERtCWD 密码:o0jd 1.ImageTarget的制作 (1).导入EasyARSD包,删 ...
- java jdbc oracle ORA-01795: 列表中的最大表达式数为 1000
在操作SQL中存在In的数量如果超过1000条会提示 ORA-01795: 列表中的最大表达式数为 1000 归纳有几种方式出现的: 第一种是:我在上一个 [jdbc 同时执行 查询和删除操]作中 ...
- windowsphone8.1学习笔记之应用数据(一)
数据存储分为两种:云存储和应用数据(即本地存储),wp中的应用数据分为两种,一种是应用设置:一种是应用文件.wp的数据相关都是通过ApplicationData来实现,一个程序只有数据存储区. 先说应 ...
- ABAP 设置单元格颜色
http://blog.163.com/ronanchen@126/blog/static/172254750201161811040488/ http://blog.csdn.net/lhx20/a ...
- LeetCode:二叉树剪枝【814】
LeetCode:二叉树剪枝[814] 题目描述 给定二叉树根结点 root ,此外树的每个结点的值要么是 0,要么是 1. 返回移除了所有不包含 1 的子树的原二叉树. ( 节点 X 的子树为 X ...
- Excel图表转成图片
关于excel 图表转成图片 知识点:excel 生成的图表不是图片 尝试. 通过Java调用POI接口挺难把excel生成的图表转成图片导出来 ps. 其它生成图表的工具,如jfre ...
- Perl 日期时间函数(date time)
use Time::HiRes qw(time);use POSIX qw(strftime); my $t = time;my $date = strftime "%Y%m%d %H:%M ...
- js中得~~是什么意思/JS按位非(~)运算符与~~运算符的理解分析
其实是一种利用符号进行的类型转换,转换成数字类型 ~~true == 1 ~~false == 0 ~~"" == 0 ~~[] == 0 ~~undefined ==0 ~~!u ...
- Protothread 机制
一.概述 很多传感器操作系统都是基于事件驱动模型的,事件驱动模型不用为每个进程都分配一个进程栈,这对内存资源受限的无线传感器网络嵌入式系统尤为重要. 然而事件驱动模型不支持阻塞等待抽象语句,因此程序员 ...
- freemaker开发
推荐书籍 百度云盘 密码: c3m9 1. 前言 本书为<FreeMarker 2.3.19 中文版手册>,包含了freemarker开发得方方面面,可以作为开发freemarker的字典 ...