/usr/include/GNUstep/Base/AdMatrix.h is in adun.app 0.81-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | /*
Project: Adun
Copyright (C) 2005 Michael Johnston & Jordi Villa-Freixa
Author: Michael Johnston
This application 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 2 of the License, or (at your option) any later version.
This application 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
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _ADUN_MATRIX_
#define _ADUN_MATRIX_
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
//! \brief Structure for int matrices
/**
\ingroup Types
*/
typedef struct
{
int no_rows;
int no_columns;
int** matrix;
}
IntMatrix;
//! \brief Structure for float matrices
/**
\ingroup Types
*/
typedef struct floatmatrix
{
int no_rows;
int no_columns;
float** matrix;
}
FloatMatrix;
//! \brief Structure for double matrices
/**
\ingroup Types
*/
typedef struct doublematrix
{
int no_rows;
int no_columns;
double** matrix;
}
DoubleMatrix;
/**
Structure for storing a sparse matrix.
*/
typedef struct
{
unsigned int no_rows;
unsigned int no_columns;
unsigned int numberNonZero; //!< The space available for non zero elements
unsigned int numberAdded; //!< Indicates how many elements have been added to the matrix
int* rowArray;
int* columnArray;
double* values;
}
AdSparseMatrix;
/**
Structure providing access to a row of a sparse matrix
*/
typedef struct
{
unsigned int length;
int* columnIndexes;
double* columnValues;
}
AdSparseMatrixRow;
typedef double AdMatrixSize;
//typedefs for AdMatrix - we make AdMatrix refer to the DoubleMatrix type
typedef DoubleMatrix AdMatrix;
//prototypes
/**
\defgroup matrix Matrix
\ingroup Functions
@{
*/
/**
Returns true if the two matrices have the same dimensions, false otherwise.
*/
bool AdCheckDoubleMatrixDimensions(DoubleMatrix *matrixOne, DoubleMatrix *matrixTwo);
/**
Returns true if the absolute difference between every corresponding element of the two matrices
is less than tolerance, otherwise returns false.
Also returns false if the matrices do not have the same dimension.
*/
bool AdCompareDoubleMatrices(DoubleMatrix *matrixOne, DoubleMatrix *matrixTwo, double tolerance);
void AdSetDoubleMatrixWithValue(DoubleMatrix *, double);
void AdSetFloatMatrixWithValue(FloatMatrix *, float);
void AdSetIntMatrixWithValue(IntMatrix *, int);
IntMatrix* AdIntMatrixFromRowSection(IntMatrix *, int , int);
FloatMatrix* AdFloatMatrixFromRowSection(FloatMatrix *, int , int);
DoubleMatrix* AdDoubleMatrixFromRowSection(DoubleMatrix *, int , int);
IntMatrix* AdIntMatrixFromRowSelection(IntMatrix *, int* , int);
FloatMatrix* AdFloatMatrixFromRowSelection(FloatMatrix *, int* , int);
DoubleMatrix* AdDoubleMatrixFromRowSelection(DoubleMatrix *, int* , int);
IntMatrix* AdIntMatrixFromColumnSection(IntMatrix *, int , int);
FloatMatrix* AdFloatMatrixFromColumnSection(FloatMatrix *, int , int);
DoubleMatrix* AdDoubleMatrixFromColumnSection(DoubleMatrix *, int , int);
IntMatrix* AdIntMatrixFromColumnSelection(IntMatrix *, int* , int);
FloatMatrix* AdFloatMatrixFromColumnSelection(FloatMatrix *, int* , int);
DoubleMatrix* AdDoubleMatrixFromColumnSelection(DoubleMatrix *, int* , int);
void AdFreeDoubleMatrix(DoubleMatrix*);
void AdFreeIntMatrix(IntMatrix*);
void AdFreeFloatMatrix(FloatMatrix*);
IntMatrix* AdAllocateIntMatrix(int, int);
FloatMatrix* AdAllocateFloatMatrix(int, int);
DoubleMatrix* AdAllocateDoubleMatrix(int, int);
/**
AdMatrix copy function.
*/
void AdCopyAdMatrixToAdMatrix(DoubleMatrix*, DoubleMatrix*);
/**
@}
*/
/**
\defgroup sparseMatrix Sparse Matrix
Aduns sparse matrix format is a storage device and not intended for use with sparse-matrix algorithms.
In this case using a dedicated sparse matrix library is required.
\ingroup Functions
@{
*/
/**
Allocates a structure for storing a sparse matrix of dimension \e numberRows * \e numberColumns
with \e nonZero non zero entries.
Free the matrix using AdFreeSparseMatrix()
*/
AdSparseMatrix* AdAllocateSparseMatrix(unsigned int numberRows, unsigned int numberColumns, unsigned int nonZero);
/**
Frees a matrix allocated using AdAllocateSparseMatrix()
*/
void AdFreeSparseMatrix(AdSparseMatrix* matrix);
/**
Adds \e value as the (\e rowIndex, \e columnIndex) entry of \e matrix.
The matrix can only be filled in row order.
That is you must add elements starting from the first non zero entry and proceeding across rows.
(columnIndex must be greater than that of the last added entry and rowIndex must be equal to or greater
than that of the last added entry)
*/
void AdSparseMatrixAddElement(AdSparseMatrix* matrix, unsigned int rowIndex, unsigned int columnIndex, double* value);
/**
As AdSparseMatrixAddElement() but performs a number of checks to ensure the addition is valid.
If its not the function returns immediately with a return value of 1, otherwise it returns 0.
*/
int AdSparseMatrixSafeAddElement(AdSparseMatrix* matrix, unsigned int rowIndex, unsigned int columnIndex, double* value);
/**
Returns the number of non-zero elements in row \e rowIndex of \e matrix
*/
int AdSparseMatrixRowLength(AdSparseMatrix* matrix, unsigned int rowIndex);
/**
Sets the AdSparseRow structure \e row with information on the indexes of the columns of row \e rowIndex
that have non zero values along with their values.
row->length is the number of non-zero elements in the row.
row->columnValues[i] gives the i^th non-zero value in the row while row->columnIndexes[i] gives the corresponding column index.
*/
void AdSparseMatrixRowElements(AdSparseMatrix* matrix, unsigned int rowIndex, AdSparseMatrixRow* row);
/** \}**/
#endif
|