Commit fe26cd2d authored by Chris Müller's avatar Chris Müller

fix matrix header and implementation file for correct compilation.

parent 1819efb7
......@@ -3,16 +3,17 @@ set(DESCRIPTION "Crystal Core Libs")
set(VERSION "0.1")
set(SOURCES
standard.c
matrix.c
)
set(HEADER
standard.h
matrix.h
)
add_library(${LIB} SHARED ${SOURCES})
configure_file(${CMAKE_SOURCE_DIR}/pkgconfig.pc.in ${CMAKE_BINARY_DIR}/pkgconfig.pc @ONLY)
configure_file(pkgconfig.pc.in ${CMAKE_BINARY_DIR}/pkgconfig.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/pkgconfig.pc DESTINATION lib/pkgconfig RENAME ${LIB}.pc)
install(FILES ${LIB} DESTINATION lib)
......
#include <stdlib.h>
#include "matrix.h"
CrySingleMatrix
cry_singlematrix_new(unsigned int rows, unsigned int cols, float default)
cry_singlematrix_new(unsigned int rows, unsigned int cols, float value)
{
float* p = 0;
float* data = cry_calloc(float, rows * cols);
CrySingleMatrix matrix = { .data = data, .rows = rows, .cols = cols };
for(p = data; p < data + rows * cols; ++p)
*p = value;
return matrix;
}
CryDoubleMatrix
cry_doublematrix_new(unsigned int rows, unsigned int cols, double default)
cry_doublematrix_new(unsigned int rows, unsigned int cols, double value)
{
double* p = 0;
double* data = cry_calloc(double, rows * cols);
CryDoubleMatrix matrix = { .data = data, .rows = rows, .cols = cols };
for(p = data; p < data + rows * cols; ++p)
*p = value;
return matrix;
}
/*
CrySingleMatrix
cry_singlematrix_identity_new(unsigned int dim)
{
double* p = 0;
double* data = cry_calloc(float, dim * dim);
CrySingleMatrix matrix = { .data = data, .rows = dim, .cols = dim };
for(p = data; p < data + dim * dim;
}
CryDoubleMatrix
cry_doublematrix_identity_new(unsigned int dim)
{
}
*/
/*
CrySingleMatrix
cry_singlematrix_from_io(FILE* io)
{
......@@ -46,5 +83,5 @@ void
cry_doublematrix_free(CryDoubleMatrix matrix)
{
}
*/
......@@ -11,10 +11,14 @@ struct CryMatrix {
typedef struct CryMatrix CrySingleMatrix;
typedef struct CryMatrix CryDoubleMatrix;
crydefine__tuple(CryMatrix, tuple_matrix);
crydefine__tuple(struct CryMatrix, tuple_matrix);
CrySingleMatrix cry_singlematrix_new(unsigned int rows, unsigned int cols, float default);
CryDoubleMatrix cry_doublematrix_new(unsigned int rows, unsigned int cols, double default);
CrySingleMatrix cry_singlematrix_new(unsigned int rows, unsigned int cols, float value);
CryDoubleMatrix cry_doublematrix_new(unsigned int rows, unsigned int cols, double value);
/*
CrySingleMatrix cry_singlematrix_identity_new(unsigned int dim);
CryDoubleMatrix cry_doublematrix_identity_new(unsigned int dim);
CrySingleMatrix cry_singlematrix_from_io(FILE* io);
CryDoubleMatrix cry_doublematrix_from_io(FILE* io);
......@@ -24,5 +28,6 @@ void cry_doublematrix_print(FILE* io, CryDoubleMatrix matrix);
void cry_singlematrix_free(CrySingleMatrix matrix);
void cry_doublematrix_free(CryDoubleMatrix matrix);
*/
#endif // CRYSTAL_MACHINELEARNING_MATRIX_H
......@@ -21,4 +21,9 @@ crydefine__tuple(long, tuple_long);
crydefine__tuple(double, tuple_double);
crydefine__tuple(float, tuple_float);
#define cry_malloc(Type) malloc(sizeof(Type))
#define cry_calloc(Type, num) calloc(num, sizeof(Type))
#define cry_realloc(Type, Pointer, num) realloc(Pointer, sizeof(Pointer) * num)
#define cry_free(Pointer) free(Pointer)
#endif // CRYSTAL_STANDARD_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment