Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 33CF9200D3E for ; Thu, 12 Oct 2017 08:16:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 325401609E5; Thu, 12 Oct 2017 06:16:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7657A160BE3 for ; Thu, 12 Oct 2017 08:16:09 +0200 (CEST) Received: (qmail 95513 invoked by uid 500); 12 Oct 2017 06:16:08 -0000 Mailing-List: contact issues-help@hivemall.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hivemall.incubator.apache.org Delivered-To: mailing list issues@hivemall.incubator.apache.org Received: (qmail 95504 invoked by uid 99); 12 Oct 2017 06:16:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Oct 2017 06:16:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id F0D381A08DF for ; Thu, 12 Oct 2017 06:16:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.021 X-Spam-Level: X-Spam-Status: No, score=-4.021 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id KV6WOasYweQ6 for ; Thu, 12 Oct 2017 06:16:06 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id F17C25FC8D for ; Thu, 12 Oct 2017 06:16:04 +0000 (UTC) Received: (qmail 95398 invoked by uid 99); 12 Oct 2017 06:16:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Oct 2017 06:16:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 74148DFADA; Thu, 12 Oct 2017 06:16:03 +0000 (UTC) From: takuti To: issues@hivemall.incubator.apache.org Reply-To: issues@hivemall.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-hivemall pull request #121: [HIVEMALL-151] Support Matrix conversi... Content-Type: text/plain Message-Id: <20171012061603.74148DFADA@git1-us-west.apache.org> Date: Thu, 12 Oct 2017 06:16:03 +0000 (UTC) archived-at: Thu, 12 Oct 2017 06:16:10 -0000 Github user takuti commented on a diff in the pull request: https://github.com/apache/incubator-hivemall/pull/121#discussion_r144195570 --- Diff: core/src/main/java/hivemall/math/matrix/MatrixUtils.java --- @@ -70,4 +77,259 @@ public void apply(int i, int value) { return which.getValue(); } + /** + * @param data non-zero entries + */ + @Nonnull + public static CSRMatrix coo2csr(@Nonnull final int[] rows, @Nonnull final int[] cols, + @Nonnull final double[] data, @Nonnegative final int numRows, + @Nonnegative final int numCols, final boolean sortColumns) { + final int nnz = data.length; + Preconditions.checkArgument(rows.length == nnz); + Preconditions.checkArgument(cols.length == nnz); + + final int[] rowPointers = new int[numRows + 1]; + final int[] colIndicies = new int[nnz]; + final double[] values = new double[nnz]; + + coo2csr(rows, cols, data, rowPointers, colIndicies, values, numRows, numCols, nnz); + + if (sortColumns) { + sortIndicies(rowPointers, colIndicies, values); --- End diff -- I found lots of typos `indicies` in many different classes...it's `indices` ---