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 ...
随机推荐
- Mac 常用属性
如果需要让隐藏的文件可见. 具体做法就是打开一个Terminal终端窗口,输入以下命令: 对于OS X Mavericks 10.9: defaults write com.apple.finder ...
- 更精炼更专注的RTMPClient客户端EasyRTMPClient,满足直播、转发、分析等各种需求
现状 EasyRTMPClient,熟悉的朋友就会联想到EasyRTSPClient项目(https://github.com/EasyDSS/EasyRTSPClient),EasyRTSPClie ...
- Eclipse项目中引用第三方jar包时将项目打包成jar文件的两种方式
转载自:http://www.cnblogs.com/lanxuezaipiao/p/3291641.html 方案一:用Eclipse自带的Export功能 步骤1:准备主清单文件 “MANIFES ...
- 九度OJ 1165:字符串匹配 (模式匹配)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3219 解决:1149 题目描述: 读入数据string[ ],然后读入一个短字符串.要求查找string[ ]中和短字符串的所有匹配,输出 ...
- mac上完整卸载删除.简单粗暴无脑:androidstudio删除方案
如果你是mac ,你删除as ,删不干净也正常,你会发现安装的时候,前面的东西也在.配置文件在,会导致你以前的错误不想要的东西都在. 废话不多说,复制粘贴就是干!!!!~~~~~~~~ 第一步: 复 ...
- CentOS 7 安装、配置、使用 PostgreSQL 9.5(一)安装及基础配置
一直不知道怎么读这个数据库的名字,在官网上找到了文档.PostgreSQL is pronounced Post-Gres-Q-L. 读音 What is PostgreSQL? How is it ...
- php+mysql 安全
Php注入攻击是现今最流行的攻击方式,依靠它强大的灵活性吸引了广大黑迷. 在上一期的<php安全与注射专题>中林.linx主要讲述了php程序的各种漏洞,也讲到了php+mysql注入的问 ...
- Python运维编程
Python运维编程 作者:Danbo 2015-10-11 什么是Python,为什么要使用Python? 这个大家自行谷歌,不过看看知乎你就知道Python有多么强大:http://www.zh ...
- ubuntu部分常用操作指令记录
# 以ROOT权限打开图形文件管理界面: sudo nautilus # 给某个文件添加可执行权限,例如: sudo chmod +x /usr/lib/jdk/bin/java # 修改某个文件或文 ...
- ubuntu下安装redis以及redis客户端在mac下的使用
ubuntu下安装redis http://blog.fens.me/linux-redis-install/ 此方式利用brew安装包去获取最新的rdm客户端 资源失效了 https://www.j ...