static void denormalize_homography(double *params, double *T1, double *T2) { double iT2[9]; double params2[9]; invnormalize_mat(T2, iT2); multiply_mat(params, T1, params2, 3, 3, 3); multiply_mat(iT2, params2, params, 3, 3, 3); }
int main(int argc, char **argv){ MPI_Init(argc, argv); MPI_Barrier(MPI_COMM_WORLD); int nb; int rank = -1; double t,start,stop; double* mat_A; double* mat_B; double* mat_res = alloc_mat(); // Allocations mat_A = init_mat(); mat_B = init_mat(); // Init printf("Nb.threads\tTps.\n"); for(nb=1;nb<=PROC;nb++){ MPI_Comm_size(MPI_COMM_WORLD, &nb); MPI_Comm_rank(MPI_COMM_WORLD, &rank); start = get_time(); multiply_mat(mat_A, mat_B, mat_res); stop=get_time(); t=stop-start; printf("%d\t%f\n",nb,t); } // Memory free free(mat_A); free(mat_B); free(mat_res); return EXIT_SUCCESS; MPI_Finalize(void); }
static int find_affine(int np, double *pts1, double *pts2, double *mat) { const int np2 = np * 2; double *a = (double *)aom_malloc(sizeof(*a) * np2 * 13); double *b = a + np2 * 6; double *temp = b + np2; int i; double sx, sy, dx, dy; double T1[9], T2[9]; normalize_homography(pts1, np, T1); normalize_homography(pts2, np, T2); for (i = 0; i < np; ++i) { dx = *(pts2++); dy = *(pts2++); sx = *(pts1++); sy = *(pts1++); a[i * 2 * 6 + 0] = sx; a[i * 2 * 6 + 1] = sy; a[i * 2 * 6 + 2] = 0; a[i * 2 * 6 + 3] = 0; a[i * 2 * 6 + 4] = 1; a[i * 2 * 6 + 5] = 0; a[(i * 2 + 1) * 6 + 0] = 0; a[(i * 2 + 1) * 6 + 1] = 0; a[(i * 2 + 1) * 6 + 2] = sx; a[(i * 2 + 1) * 6 + 3] = sy; a[(i * 2 + 1) * 6 + 4] = 0; a[(i * 2 + 1) * 6 + 5] = 1; b[2 * i] = dx; b[2 * i + 1] = dy; } if (pseudo_inverse(temp, a, np2, 6)) { aom_free(a); return 1; } multiply_mat(temp, b, mat, 6, np2, 1); denormalize_affine_reorder(mat, T1, T2); aom_free(a); return 0; }