/* ************************************************************   
   *                                                          *   
   *     Elementare numerische Methoden der Mathematik        *   
   *                                                          *   
   *     Arbeiten mit matrixwertigen Funktionen               *   
   *                                                          *   
   *     (c) 2010 Jens Burmeister, Universitaet Kiel,         *   
   *              Institut fuer Informatik                    *   
   *              Lehrstuhl  Scientific Computing             *   
   *                                                          *   
   *     Version 1.0 vom  Tue Jan 12 15:33:24 MET 2010        *   
   *                                                          *   
   ************************************************************ */

#include <stdlib.h>   
  /*  wegen malloc                                 */
#include "Vectors.h"                
  /* wegen PVector                                 */
#include "VectorValuedFunctions.h" 
  /* wegen PVectorValuedFunction                   */
#include "MatrixValuedFunctions.h"  
  /* wegen PMatrixValuedFunction                   */
  /* wegen TMatrixValuedFunction_Create            */
  /* wegen TMatrixValuedFunction_Destroy           */
  /* wegen TMatrixValuedFunction_Evaluate          */
  /* wegen TMatrixValuedFunction_Evaluate_Create   */

PMatrixValuedFunction TMatrixValuedFunction_Create(int m, int n){
  PMatrixValuedFunction  F;
  int i;
  F = (PMatrixValuedFunction) malloc(m * sizeof(PVectorValuedFunction));
  for ( i=0; i<m; i=i+1 ) 
    F[i] = TVectorValuedFunction_Create(n);
  return F;
}

void TMatrixValuedFunction_Destroy(int m, int n, PMatrixValuedFunction F){
  int i;
  for ( i=0; i<m; i=i+1 ) 
    free(F[i]);
  free(F);
}

void TMatrixValuedFunction_Evaluate(int m, int n, PMatrix A, PMatrixValuedFunction F, PVector x){

  int i, j;

  for (i=0; i<m; i=i+1) {
    for (j=0; j<n; j=j+1) A[i][j] = F[i][j](n, x);
  }

}

PMatrix TMatrixValuedFunction_Evaluate_Create(int m, int n, PMatrixValuedFunction F, PVector x){

  PMatrix A;

  A = TMatrix_Create(m, n);
  TMatrixValuedFunction_Evaluate(m, n, A, F, x);
  
  return A;  
}

/* ***************************************************************************   
   *                                                                         *   
   *     Logbuch fuer  MatrixValuedFunctions.c                               *   
   *  ------------------------------------------------------------------     *   
   *                                                                         *   
   *     Version 1.0 vom Tue Jan 12 17:06:20 MET 2010                        *   
   *                                                                         *   
   *     - Funktionen erzeugt                                                *   
   *                                                                         *   
   *       PMatrixValuedFunction TMatrixValuedFunction_Create(int, int);     *
   *       void TMatrixValuedFunction_Destroy(PMatrixValuedFunction);        *
   *                                                                         *
   *       void TMatrixValuedFunction_Evaluate(                              *
   *              int, int, PMatrix, PMatrixVectorValuedFunction, PVector);  *
   *       PMatrix TMatrixValuedFunction_Evaluate_Create(                    *
   *                 int, int, PMatrixValuedFunction, PVector);              *
   *                                                                         *   
   ************************************************************************* */

