Hitmap 1.3
|
#include <stdio.h>
#include <stdlib.h>
#include <hitmap.h>
#include <hit_com.h>
#include <unistd.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | Vector |
struct | Matrix |
Macros | |
#define | D (3) |
#define | K (1) |
#define | L (0.001) |
#define | P_FIXED 10 |
#define | ITER1 10 |
#define | ITER2 100 |
#define | clearV(vv) clearVInternal((vv).v) |
#define | clearVInternal(v) ((v)[0] = (v)[1] = (v)[2] = 0.0 ) |
#define | cpyV(r, a) cpyVInternal((r).v,(a).v) |
#define | cpyVInternal(r, a) {(r)[0] = (a)[0]; (r)[1] = (a)[1]; (r)[2] = (a)[2]; } |
#define | addV(r, a, b) addVInternal((r).v,(a).v,(b).v) |
#define | addVInternal(r, a, b) {(r)[0] = (a)[0] + (b)[0]; (r)[1] = (a)[1] + (b)[1]; (r)[2] = (a)[2] + (b)[2]; } |
#define | subV(r, a, b) subVInternal((r).v,(a).v,(b).v) |
#define | subVInternal(r, a, b) {(r)[0] = (a)[0] - (b)[0]; (r)[1] = (a)[1] - (b)[1]; (r)[2] = (a)[2] - (b)[2]; } |
#define | norm(vv) normInternal((vv).v) |
#define | normInternal(v) (sqrt( pow((v)[0],2) + pow((v)[1],2) + pow((v)[2],2) )) |
#define | multSV(r, s, vv) multSVInternal((r).v,s,(vv).v) |
#define | multSVInternal(r, s, v) {(r)[0] = (s) * (v)[0]; (r)[1] = (s) * (v)[1]; (r)[2] = (s) * (v)[2]; } |
#define | clearM(mm) clearMInternal((mm).m) |
#define | clearMInternal(m) |
#define | det(mm) detInternal((mm).m) |
#define | detInternal(m) |
#define | init_matrix(mm, a, b, c, d, e, f, g, h, i) init_matrixInternal((mm).m,a,b,c,d,e,f,g,h,i) |
#define | init_matrixInternal(m, a, b, c, d, e, f, g, h, i) |
#define | multSM(r, s, mm) multSMInternal((r).m,s,(mm).m) |
#define | multSMInternal(r, s, m) |
#define | multSI(r, s) multSIInternal((r).m,s) |
#define | multSIInternal(r, s) |
#define | addM(r, a, b) addMInternal((r).m,(a).m,(b).m) |
#define | addMInternal(r, a, b) |
#define | multVVt(r, a, b) multVVtInternal((r).m,(a).v,(b).v) |
#define | multVVtInternal(r, a, b) |
#define | multMV(r, mm, vv) multMVInternal((r).v,(mm).m,(vv).v) |
#define | multMVInternal(r, m, v) |
#define | inv(r, mm) invInternal((r).m,(mm).m) |
#define | invInternal(r, m) |
#define | multMM(r, a, b) multMMInternal((r).m,(a).m,(b).m) |
#define | multMMInternal(r, a, b) |
#define | ITER_SJ 10 |
Functions | |
hit_tileNewType (Vector) | |
hit_tileNewType (Matrix) | |
hit_tileNewType (int) | |
void | calculate_GH (int vertex) |
void | solve_system_iter (int vertex) |
Vector | solve_jacobi (Matrix A, Vector b) |
Vector | solve (Matrix A, Vector b) |
void | init_structures () |
void | free_structures () |
void | print_help (char *name) |
void | random_coordinates () |
void | init_graph (int argc, char **argv) |
double | gradient_norm () |
int | main (int argc, char **argv) |
Vector | g (int i, int j) |
Matrix | W (int i, int j) |
Variables | |
int | iter1 = ITER1 |
int | iter2 = ITER2 |
HitTile_Vector | gradient |
HitTile_Matrix | hessian |
HitTile_Vector | e |
HitTile_Vector | new_e |
HitShape | shape |
HitTile_Vector | graph |
HitTile_int | fixed |
Calculate the stable position of a spring system. Sequential hitmap version of the benchmark using a bitmap structure.
This is the same code from spring_csr_sec with the following changes: Changed hit_cShape* -> hit_bShape* Changed hit_gcTile* -> hit_gbTile* Changed HIT_CSR_SHAPE_NULL -> HIT_BITMAP_SHAPE_NULL Changed hit_fileHBRead -> hit_fileHBReadBitmap
Definition in file spring_bitmap_sec.c.
Add two matrix, r = a + b.
Definition at line 268 of file spring_bitmap_sec.c.
#define addMInternal | ( | r, | |
a, | |||
b | |||
) |
Definition at line 269 of file spring_bitmap_sec.c.
Add two vectors, r = a + b.
Definition at line 183 of file spring_bitmap_sec.c.
#define addVInternal | ( | r, | |
a, | |||
b | |||
) | {(r)[0] = (a)[0] + (b)[0]; (r)[1] = (a)[1] + (b)[1]; (r)[2] = (a)[2] + (b)[2]; } |
Definition at line 184 of file spring_bitmap_sec.c.
#define clearM | ( | mm | ) | clearMInternal((mm).m) |
Clear a matrix.
Definition at line 212 of file spring_bitmap_sec.c.
#define clearMInternal | ( | m | ) |
#define clearV | ( | vv | ) | clearVInternal((vv).v) |
Clear a vector.
Definition at line 169 of file spring_bitmap_sec.c.
Definition at line 170 of file spring_bitmap_sec.c.
#define cpyV | ( | r, | |
a | |||
) | cpyVInternal((r).v,(a).v) |
Copy a vector.
Definition at line 176 of file spring_bitmap_sec.c.
Definition at line 177 of file spring_bitmap_sec.c.
#define D (3) |
Number of dimensions.
Definition at line 57 of file spring_bitmap_sec.c.
#define det | ( | mm | ) | detInternal((mm).m) |
Calculate the determinant.
a b c d e f g h i
det = aei + bfg + cdh - afh - bdi - ceg
Definition at line 228 of file spring_bitmap_sec.c.
#define detInternal | ( | m | ) |
Definition at line 229 of file spring_bitmap_sec.c.
Initialization of a matrix.
Definition at line 240 of file spring_bitmap_sec.c.
Definition at line 241 of file spring_bitmap_sec.c.
Inverses a matrix.
Definition at line 298 of file spring_bitmap_sec.c.
Definition at line 299 of file spring_bitmap_sec.c.
#define ITER1 10 |
Default number of iterations for the Newton-Raphson method.
Definition at line 68 of file spring_bitmap_sec.c.
#define ITER2 100 |
Default number of iterations for the Jacobi method.
Definition at line 70 of file spring_bitmap_sec.c.
#define ITER_SJ 10 |
#define K (1) |
Spring constant.
Definition at line 60 of file spring_bitmap_sec.c.
#define L (0.001) |
Spring length.
Definition at line 62 of file spring_bitmap_sec.c.
Multiplies two matrices.
Definition at line 314 of file spring_bitmap_sec.c.
#define multMMInternal | ( | r, | |
a, | |||
b | |||
) |
Definition at line 315 of file spring_bitmap_sec.c.
Multiplies a matrix with a vector.
Definition at line 288 of file spring_bitmap_sec.c.
Definition at line 289 of file spring_bitmap_sec.c.
Multiplication scalar x identity matrix.
Definition at line 258 of file spring_bitmap_sec.c.
Multiplication scalar x matrix.
Definition at line 249 of file spring_bitmap_sec.c.
Definition at line 250 of file spring_bitmap_sec.c.
Multiplication scalar x vector.
Definition at line 205 of file spring_bitmap_sec.c.
#define multSVInternal | ( | r, | |
s, | |||
v | |||
) | {(r)[0] = (s) * (v)[0]; (r)[1] = (s) * (v)[1]; (r)[2] = (s) * (v)[2]; } |
Definition at line 206 of file spring_bitmap_sec.c.
Multiply a vector with a transposed vector. the result is a matrix.
Definition at line 278 of file spring_bitmap_sec.c.
#define multVVtInternal | ( | r, | |
a, | |||
b | |||
) |
Definition at line 279 of file spring_bitmap_sec.c.
#define norm | ( | vv | ) | normInternal((vv).v) |
Calculate the norm of a vector
Definition at line 198 of file spring_bitmap_sec.c.
Definition at line 199 of file spring_bitmap_sec.c.
#define P_FIXED 10 |
Percentage of fixed points
Definition at line 65 of file spring_bitmap_sec.c.
Subtract two vectors, r = a - b.
Definition at line 191 of file spring_bitmap_sec.c.
#define subVInternal | ( | r, | |
a, | |||
b | |||
) | {(r)[0] = (a)[0] - (b)[0]; (r)[1] = (a)[1] - (b)[1]; (r)[2] = (a)[2] - (b)[2]; } |
Definition at line 192 of file spring_bitmap_sec.c.
void calculate_GH | ( | int | vertex | ) |
Function to calculate the gradient and hessian for a given node. Gradient: gs_i = Sum_j gij
vertex | The vertex index. |
void free_structures | ( | ) |
Release the memory
Definition at line 416 of file spring_bitmap_sec.c.
Vector g | ( | int | i, |
int | j | ||
) |
Auxiliar function to get the gradient.
Definition at line 714 of file spring_bitmap_sec.c.
double gradient_norm | ( | ) |
Calculate the norm of the whole gradient vector.
Definition at line 609 of file spring_bitmap_sec.c.
hit_tileNewType | ( | Vector | ) |
hit_tileNewType | ( | Matrix | ) |
hit_tileNewType | ( | int | ) |
void init_graph | ( | int | argc, |
char ** | argv | ||
) |
Init the graph
Definition at line 486 of file spring_bitmap_sec.c.
void init_structures | ( | ) |
Allocate memory of all the variables
Definition at line 405 of file spring_bitmap_sec.c.
int main | ( | int | argc, |
char ** | argv | ||
) |
Main function
Definition at line 638 of file spring_bitmap_sec.c.
void print_help | ( | char * | name | ) |
void random_coordinates | ( | ) |
Generate random coordinates for the spring nodes. It also set the fixed nodes
Definition at line 448 of file spring_bitmap_sec.c.
Solve a linear system. It calculates the inverse matrix. If the matrix is singular, it use the jacobi method to get an approximation. Ax=b.
A | The coefficients matrix. |
b | The constant terms vector. |
Definition at line 383 of file spring_bitmap_sec.c.
Solve a linear system using the jacobi method. Ax=b.
A | The coefficients matrix. |
b | The constant terms vector. |
Definition at line 334 of file spring_bitmap_sec.c.
void solve_system_iter | ( | int | vertex | ) |
Function that solves a iteration of the jacobi method for a given node.
vertex | The vertex index. |
Function that solves a iteration of the jacobi method for a given node. e_i = H_ii^(-1) * (Gi - SUM_{i not j} ( Hij e_j ) )
vertex | The vertex index. |
Matrix W | ( | int | i, |
int | j | ||
) |
Auxiliary function to get the hessian.
Definition at line 751 of file spring_bitmap_sec.c.
HitTile_Vector e |
Vector with the position increase.
Definition at line 109 of file spring_bitmap_sec.c.
HitTile_int fixed |
Tile with the fixed/free status
Definition at line 121 of file spring_bitmap_sec.c.
HitTile_Vector gradient |
Gradient array part for each node.
Definition at line 103 of file spring_bitmap_sec.c.
HitTile_Vector graph |
Tile with the node values.
Definition at line 118 of file spring_bitmap_sec.c.
HitTile_Matrix hessian |
Hessian matrix part for each edge.
Definition at line 106 of file spring_bitmap_sec.c.
int iter1 = ITER1 |
Number of iterations for the Newton-Raphson method.
Definition at line 73 of file spring_bitmap_sec.c.
int iter2 = ITER2 |
Number of iterations for the Jacobi method.
Definition at line 75 of file spring_bitmap_sec.c.
HitTile_Vector new_e |
Vector with the new position increase.
Definition at line 112 of file spring_bitmap_sec.c.
HitShape shape |
Hit shape defining the spring structure.
Definition at line 115 of file spring_bitmap_sec.c.