blob: eab6b4ddcc4034ba3c8a711aa0ac58ba25161768 [file] [log] [blame]
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------
# Utility script to append 1 matrix to another and apply row range
# indexing. This is used for R cbind() like functionality returning
# the head() of the result.
#
# Parameters:
# x : (input) 1st data set
# y : (input) 2nd data set
# n : (input) number of rows to return, i.e.: 1:n
# o : (output)
# ofmt : (default "csv"); format of output
#
# Example:
# hadoop jar SystemML.jar -f algorithms/utils/cbind.dml -nvargs x="/tmp/M.mtx" y="/tmp/M1.mtx" n=100 o="/tmp/o.mtx"
#
ofmt = ifdef ($ofmt, "csv");
x = read ($x);
y = read ($y);
if ($n == nrow(x))
{
xp = x;
yp = y;
}
else
{
xp = x[1:$n,];
yp = y[1:$n,];
}
o = append (xp, yp);
write (o, $o, format=ofmt);