{- | HasGP Gaussian Process Library. This module contains assorted
functions that support the construction of matrices from
functions.
Copyright (C) 2011 Sean Holden. sbh11\@cl.cam.ac.uk.
-}{- This file is part of HasGP.
HasGP is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
HasGP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with HasGP. If not, see <http://www.gnu.org/licenses/>.
-}moduleHasGP.Support.MatrixFunctionwhereimportNumeric.LinearAlgebraimportHasGP.Types.MainTypesimportHasGP.Support.FunctionsasF-- | Take two vectors and a function. The vectors contain inputs 1 and 2. -- The function maps a pair of inputs to a value. Produce a matrix -- containing the values of the function at the relevant points.makeMatrixFromFunction2::(DVector->Double)->DVector->DVector->DMatrixmakeMatrixFromFunction2fx1x2=flipud$((lengthx1L)><(lengthx2L))(mapfl)wherex1L=toListx1x2L=toListx2l=mapfromList[[a,b]|a<-x1L,b<-x2L]-- | Take a function and a matrix of instance vectors. Apply the function to -- each possible pair of instance vectors and return the result as a matrix.makeMatrixFromPairs2::(DVector->DVector->Double)->DMatrix->DMatrixmakeMatrixFromPairs2fi=(d><d)[fx1x2|x1<-x,x2<-x]whered=rowsix=toRowsi-- | Same as makeMatrixFromPairs but the function returns a vector. In this -- case the output is a list of matrices, one for each element of the -- function value.makeMatricesFromPairs::(DVector->DVector->DVector)->DMatrix->[DMatrix]makeMatricesFromPairsfi=map(d><d)(reArrangelists[])whered=rowsix=toRowsilists=maptoList[fx1x2|x1<-x,x2<-x]reArrange[]r=reverserreArrangel@(h:t)r|(h==[])=reverser|otherwise=reArrange(maptaill)((mapheadl):r)