borrow all of codes in dense.go from go.matrix