Madpack: Remove MADlibSchema variable

Jira: MADLIB-645
Sampling: Include macros in SQL file

Jira: MADLIB-678, MADLIB-584

File sample.sql_in did not include the file containing our predefined macros.
This implied that on Greenplum, the weighted sampling aggregate was defined
without a merge function. This severely impacted performance on multi-node
Greenplum instances.
New k-means: Query tuning

Jira: MADLIB-678

The previous optimization fence "OFFSET 0" was suitable for PostgreSQL only. 
However, an optimization fence is also needed on Greenplum -- with it the innermost
subquery can be sped up by a factor around 2.

An alternative would be moving the innermost subquery that contains the
closest_column calls into a common table expression, but unfortunately that is not
supported by earlier Greenplum versions.

It is unfortunate that we have to use such tricks, but we do not want to forgo a
factor-2 performance improvement.
Multi-logistic: Remove indication of cg/igd

Jira: MADLIB-668
SVM: Fix regression when there is no data on segments

Jira: MADLIB-677

In parallel mode, we build one sub-model for each segment.  In the combination
step, we should skip the segments with no source data.

Although it is questionable to use segment id as a logical unit of calculation,
we'll address it as a separate issue in the future.
Function for retrieving column of a matrix

Jira: MADLIB-682

The following query returns NULL in PostgreSQL:
SELECT matrix[1] FROM (SELECT ARRAY[ARRAY[1,2], ARRAY[3,4]] matrix) q;

Reason: Since PostgreSQL does not attach dimensionality to the array type 
information, it is unknown during parsing whether matrix[1] is an expression of
type INTEGER or INTEGER[]. We still want to be able to retrieve columns (or rows)
from matrices. I therefore added a function that handles this special case.
New k-means: Simplified silhouette function

Jira: MADLIB-681

Implemented a function to compute the simplified silhouette coefficient.
Additions for this functions in other parts of the code:

Matrix operations:
- Function that returns the two closest columns in a matrix (relative to a given
  vector).

C++ AL:
- Support for INTEGER arrays
Fixed oversight in previous commit that was mistakenly pushed to master

Jira: None

C++ code for distNorm1 called the wrong internal function. Unit test for
closest_columns function used SQL that Greenplum does not support.
Install create_table_as() workaround also on PostgreSQL

Jira: MADLIB-691

It is convenient to have a uniform interface for CREATE TABLE ... AS, e.g.,
when writing test cases that should run unmodified on all supported
platforms. Obviously, we then can rely on nothing more than the least common
denominator – which is that CTAS is defunct, and our SELECT create_table_as()
workaround has to be used.

In other words, the compatibility module should also be installed for the
PostgreSQL port.
Fixed flawed unit test for compatibility.sql_in

Jira: None

The old unit test had a non-zero chance of failing. There is absolutely no reason,
however, that this unit test should be non-deterministic.
Build support for PostgreSQL 9.2

Jira: MADLIB-662

The decision-tree code contained the function table_exists(), which calls
RangeVarGetRelid(), which used to be a two-parameter function, but is now a
three-paremter macro.
Revert commit 72b11c1 and provide a more suitable fix for MADLIB-637

Jira: MADLIB-637

The fix in commit 72b11c1 moved logic (i.e., the check whether the number of rows
in a state is 0) back to a place where it not supposed to be (linear.cpp).

I added a unit test that ensures the merge function behaves correctly when there are
no rows on one segment, i.e., when the merge function is called with the aggregate's
initial state in one of its arguments.
Multinomial logistic regression: Removed implicit conversion to FLOAT8

Jira: MADLIB-670

There is no reason that multinomial logistic regression should work with all
data set where the dependent variable could be cast to INTEGER. After all, this
implicit conversion could potentially cause unintended behavior for categorical
variables. For instance, different DOUBLE PRECISION values would be mapped to
the same category.

This conversion was a left-over from copied binary logistic-regression code,
where implicit conversion was to BOOLEAN. For binary logistic regression, the
benefits of implicit conversion outweighed the danger of misinterpretation
(which should be rather low for binary variables).

Other change:
- Moved an error message to a more appropriate location.
Fix compilation warning introduced with commit 845210b

Jira: MADLIB-662

Since RangeVarGetRelid() became a macro in PG9.2, embedding a preprocessor directive
within arguments should be avoided, as it is not portable.
k-means: Design document updated, some naming issues fixed

Jira: MADLIB-692

With k-means allowing to supply arbitrary distance functions and recentering
aggregates, the name k-means has become a bit of a misnomer. E.g., by supplying
the 1-norm as distance function and the element-wise median as recentering
aggregate we would compute a local minimum for the k-medians problem.
Due to the previous narrow focus on only the Euclidean case, the distance
parameter used to be called 'fn_squared_dist' and the recentering parameter
'agg_mean'. I replace them by 'fn_dist' and 'agg_centroid'.

Along the same lines, I removed the distance functions 'squared_dist_1norm',
'squared_angle', and 'squared_tanimoto', and only kept 'dist_1norm', 'dist_angle',
and 'dist_tanimoto'.

Other changes:
- Added default parameters to madlib.closest_column
- Added author and version information to some modules in the design document
Multinomial logistic regression: Added variable number limitation to documentation

Jira: MADLIB-665

In multinomial logistic regression, the number of independent variables cannot
exceed 65535. This limitation was added to the usage section of the
documentation.
Logistic regression: Fixed a minor problem with direction restart in cg

Jira: MADLIB-574

In the conjugate gradient method, the direction is restarted when
Polak-Ribière's beta <= 0 instead of <0.

Reason: In the Polak-Ribière (PR) fomula, beta is chosen as max(0,PR'beta),
so Hestenes-Stiefel's (HS) beta needs to be 0 when PR's beta <= 0 (not <0).
Otherwise, without the "=", HS's beta will blow up at the optimum solution.

Instead of comparing with 0, a small number is used.
SVM regression: Skip regression test for segments with no data

JIRA: MADLIB-690

In parallel mode, we build one sub-model for each segment.  In the test scoring, we should skip the segments with no source data.
Sketch-based estimators: Fixed unsafe use of user-supplied parameters

Jira: MADLIB-630

When the final function is called via
SELECT __cmsketch_final(''),
the function used to copy and return data that is at an offest not included in
the input bytea, which has a length shorter than sizeof(cmsketch).

Also removed all trailing white spaces.
Design document: The C++ Abstraction Layer

Jira: MADLIB-696

A first revision of documenting the C++ abstraction layer. Several classes still
need a more detailed explanation.

Other changes:
- Linear-algebra module now included in user documentation