y2x.cpp

来自「一个画有向图的程序。里面含有力导引画图算法等多个经典算法。」· C++ 代码 · 共 55 行

CPP
55
字号

#include	<stdio.h>
#include	"..\defs.h"


void      y2x(
				double  **xvecs,		/* pointer to list of x-vectors */
				int       ndims,		/* number of divisions to make (# xvecs) */
				int       nmyvtxs,		/* number of vertices I own (lenght xvecs) */
				double   *wsqrt		/* sqrt of vertex weights */
			)

/* Convert from y to x by dividing by wsqrt. */
{
    double   *wptr;		/* loops through wsqrt */
    double   *xptr;		/* loops through elements of a xvec */
    int       i, j;		/* loop counters */

    if (wsqrt == NULL)
		return;

    for (i = 1; i <= ndims; i++) {
		xptr = xvecs[i];
		wptr = wsqrt;
		for (j = nmyvtxs; j; j--) {
			*(++xptr) /= *(++wptr);
		}
    }
}


void      x2y(
				double  **yvecs,		/* pointer to list of y-vectors */
				int       ndims,		/* number of divisions to make (# yvecs) */
				int       nmyvtxs,		/* number of vertices I own (lenght yvecs) */
				double   *wsqrt 		/* sqrt of vertex weights */
			)
/* Convert from x to y by multiplying by wsqrt. */
{
    double   *wptr;		/* loops through wsqrt */
    double   *yptr;		/* loops through elements of a yvec */
    int       i, j;		/* loop counters */

    if (wsqrt == NULL)
	return;

    for (i = 1; i <= ndims; i++) {
	yptr = yvecs[i];
	wptr = wsqrt;
	for (j = nmyvtxs; j; j--) {
	    *(++yptr) *= *(++wptr);
	}
    }
}

⌨️ 快捷键说明

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