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.
Definition in file spring_csr_sec.c.
Add two matrix, r = a + b.
Definition at line 264 of file spring_csr_sec.c.
#define addMInternal | ( | r, | |
a, | |||
b | |||
) |
Definition at line 265 of file spring_csr_sec.c.
Add two vectors, r = a + b.
Definition at line 179 of file spring_csr_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 180 of file spring_csr_sec.c.
#define clearM | ( | mm | ) | clearMInternal((mm).m) |
Clear a matrix.
Definition at line 208 of file spring_csr_sec.c.
#define clearMInternal | ( | m | ) |
#define clearV | ( | vv | ) | clearVInternal((vv).v) |
Clear a vector.
Definition at line 165 of file spring_csr_sec.c.
Definition at line 166 of file spring_csr_sec.c.
#define cpyV | ( | r, | |
a | |||
) | cpyVInternal((r).v,(a).v) |
Copy a vector.
Definition at line 172 of file spring_csr_sec.c.
Definition at line 173 of file spring_csr_sec.c.
#define D (3) |
Number of dimensions.
Definition at line 53 of file spring_csr_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 224 of file spring_csr_sec.c.
#define detInternal | ( | m | ) |
Definition at line 225 of file spring_csr_sec.c.
Initialization of a matrix.
Definition at line 236 of file spring_csr_sec.c.
Definition at line 237 of file spring_csr_sec.c.
Inverses a matrix.
Definition at line 294 of file spring_csr_sec.c.
Definition at line 295 of file spring_csr_sec.c.
#define ITER1 10 |
Default number of iterations for the Newton-Raphson method.
Definition at line 64 of file spring_csr_sec.c.
#define ITER2 100 |
Default number of iterations for the Jacobi method.
Definition at line 66 of file spring_csr_sec.c.
#define ITER_SJ 10 |
#define K (1) |
Spring constant.
Definition at line 56 of file spring_csr_sec.c.
#define L (0.001) |
Spring length.
Definition at line 58 of file spring_csr_sec.c.
Multiplies two matrices.
Definition at line 310 of file spring_csr_sec.c.
#define multMMInternal | ( | r, | |
a, | |||
b | |||
) |
Definition at line 311 of file spring_csr_sec.c.
Multiplies a matrix with a vector.
Definition at line 284 of file spring_csr_sec.c.
Definition at line 285 of file spring_csr_sec.c.
Multiplication scalar x identity matrix.
Definition at line 254 of file spring_csr_sec.c.
Multiplication scalar x matrix.
Definition at line 245 of file spring_csr_sec.c.
Definition at line 246 of file spring_csr_sec.c.
Multiplication scalar x vector.
Definition at line 201 of file spring_csr_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 202 of file spring_csr_sec.c.
Multiply a vector with a transposed vector. the result is a matrix.
Definition at line 274 of file spring_csr_sec.c.
#define multVVtInternal | ( | r, | |
a, | |||
b | |||
) |
Definition at line 275 of file spring_csr_sec.c.
#define norm | ( | vv | ) | normInternal((vv).v) |
Calculate the norm of a vector
Definition at line 194 of file spring_csr_sec.c.
Definition at line 195 of file spring_csr_sec.c.
#define P_FIXED 10 |
Percentage of fixed points
Definition at line 61 of file spring_csr_sec.c.
Subtract two vectors, r = a - b.
Definition at line 187 of file spring_csr_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 188 of file spring_csr_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 412 of file spring_csr_sec.c.
Vector g | ( | int | i, |
int | j | ||
) |
Auxiliar function to get the gradient.
Definition at line 710 of file spring_csr_sec.c.
double gradient_norm | ( | ) |
Calculate the norm of the whole gradient vector.
Definition at line 605 of file spring_csr_sec.c.
hit_tileNewType | ( | Vector | ) |
hit_tileNewType | ( | Matrix | ) |
hit_tileNewType | ( | int | ) |
void init_graph | ( | int | argc, |
char ** | argv | ||
) |
Init the graph
Definition at line 481 of file spring_csr_sec.c.
void init_structures | ( | ) |
Allocate memory of all the variables
Definition at line 401 of file spring_csr_sec.c.
int main | ( | int | argc, |
char ** | argv | ||
) |
Main function
Definition at line 634 of file spring_csr_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 443 of file spring_csr_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 379 of file spring_csr_sec.c.
Solve a linear system using the jacobi method. Ax=b.
A | The coefficients matrix. |
b | The constant terms vector. |
Definition at line 330 of file spring_csr_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 747 of file spring_csr_sec.c.
HitTile_Vector e |
Vector with the position increase.
Definition at line 105 of file spring_csr_sec.c.
HitTile_int fixed |
Tile with the fixed/free status
Definition at line 117 of file spring_csr_sec.c.
HitTile_Vector gradient |
Gradient array part for each node.
Definition at line 99 of file spring_csr_sec.c.
HitTile_Vector graph |
Tile with the node values.
Definition at line 114 of file spring_csr_sec.c.
HitTile_Matrix hessian |
Hessian matrix part for each edge.
Definition at line 102 of file spring_csr_sec.c.
int iter1 = ITER1 |
Number of iterations for the Newton-Raphson method.
Definition at line 69 of file spring_csr_sec.c.
int iter2 = ITER2 |
Number of iterations for the Jacobi method.
Definition at line 71 of file spring_csr_sec.c.
HitTile_Vector new_e |
Vector with the new position increase.
Definition at line 108 of file spring_csr_sec.c.
HitShape shape |
Hit shape defining the spring structure.
Definition at line 111 of file spring_csr_sec.c.