matrix.h

Go to the documentation of this file.
00001 /**
00002  * @file ccn/matrix.h
00003  * 
00004  * Part of the CCNx C Library.
00005  *
00006  * Copyright (C) 2008, 2009 Palo Alto Research Center, Inc.
00007  *
00008  * This library is free software; you can redistribute it and/or modify it
00009  * under the terms of the GNU Lesser General Public License version 2.1
00010  * as published by the Free Software Foundation.
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014  * Lesser General Public License for more details. You should have received
00015  * a copy of the GNU Lesser General Public License along with this library;
00016  * if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
00017  * Fifth Floor, Boston, MA 02110-1301 USA.
00018  *
00019  * @brief Implements a two-dimension table containing integer values.
00020  * Although this interface is abstract, the implementation is (or will be)
00021  * tuned to the needs of ccnd.  Any value not stored will fetch as zero.
00022  *
00023  */
00024 
00025 #ifndef CCN_MATRIX_DEFINED
00026 #define CCN_MATRIX_DEFINED
00027 
00028 #include <stdint.h>
00029 
00030 struct ccn_matrix;
00031 
00032 struct ccn_matrix_bounds {
00033     uint_least64_t row_min;
00034     uint_least64_t row_max;
00035     unsigned col_min;
00036     unsigned col_max;
00037 };
00038 
00039 struct ccn_matrix *ccn_matrix_create(void);
00040 void ccn_matrix_destroy(struct ccn_matrix **);
00041 
00042 intptr_t ccn_matrix_fetch(struct ccn_matrix *m,
00043                           uint_least64_t row, unsigned col);
00044 void     ccn_matrix_store(struct ccn_matrix *m,
00045                           uint_least64_t row, unsigned col, intptr_t value);
00046 
00047 /*
00048  * ccn_matrix_getbounds:
00049  * Fills result with a (not necessarily tight) bounding box for the
00050  * non-zero elements of m.  Returns -1 in case of error, or a non-negative
00051  * value for success.
00052  */
00053 int ccn_matrix_getbounds(struct ccn_matrix *m, struct ccn_matrix_bounds *result);
00054 
00055 /*
00056  * ccn_matrix_trim:
00057  * Zeros any entries outside the bounds
00058  */
00059 int ccn_matrix_trim(struct ccn_matrix *m, const struct ccn_matrix_bounds *bounds);
00060 /*
00061  * ccn_matrix_trim:
00062  * Zeros entries inside the bounds
00063  */
00064 int ccn_matrix_clear(struct ccn_matrix *m, const struct ccn_matrix_bounds *bounds);
00065 
00066 #endif

Generated on Thu Feb 16 00:43:59 2012 for Content-Centric Networking in C by  doxygen 1.5.6