⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 renumber.c

📁 用于2维的射线追踪
💻 C
字号:
#include "renumber.h"#ifdef USE_MPIextern int rank;#endif/** \brief renumber the ray ID in the sparse file  *   @param ray_offset offset to apply to the the ray ID *   @param nb_ray_computed nb rays computed by all slaves *   @param sparse_filename sparse filename */void renumber_sparse_file (long int ray_offset, long int nb_ray_computed, 			   char *sparse_filename) {	long int i;	struct sparse_matrix_t *a;	struct sparse_item_t *cur_item;#ifdef USE_MPI	fprintf(stdout, "*** [process %d] renumbering sparse file '%s' (offset=%ld)\n", 			rank, sparse_filename, ray_offset);#else	fprintf(stdout, "renumbering sparse file '%s' (offset=%ld)\n", 			sparse_filename, ray_offset);#endif	a = read_sparse_matrix (sparse_filename, SPARSE_COL_LINK);	/* resize the matrix accordingly to the number of computed rays 	 * by all the slaves */		/* change rayid -> change the line_index */	for (i=0; i < a->nb_line; i++) {		cur_item = a->line[i];		while (cur_item) {			cur_item->line_index += ray_offset;				cur_item = cur_item->next_in_line;		}	}	write_sparse_matrix (a, sparse_filename);	free_sparse_matrix (a);}/** \brief renumber the ray ID in the res file  *   @param ray_offset offset to apply to the the ray ID *   @param nb_rays_computed nb total of rays traced *   @param filename residual filename */void renumber_res_file (long int ray_offset, long int nb_rays_computed, 			char *filename) {	struct vector_t *res;	long int i, first, last;	FILE *fd;	fprintf(stdout, "renumbering res file '%s' (offset=%ld)\n", 			filename, ray_offset);	res = read_subvector(filename, &first, &last);	/* re-open the file */	if (!(fd = fopen(filename, "w"))) {		perror(filename);		exit(1);	}	fprintf(fd, "%ld\n", nb_rays_computed);	for (i = first; i <= last; i++) {		fprintf(fd, "%ld %f\n", i+ray_offset, res->mat[i]);	}	fclose(fd);	free_vector(res);}/** \brief renumber the ray ID in the event file  *   @param ray_offset offset to apply to the the ray ID *   @param nb_rays_computed nb total of rays traced *   @param filename event filename */void renumber_evt_file (long int ray_offset, long int nb_rays_computed, 		        char *filename) {	fprintf(stdout, "renumbering evt file '%s' (offset=%ld) NOT YET IMPLEMENTED\n", 			filename, ray_offset);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -