示例#1
0
/*
  Get input from the keyboard until the symbol ‘@’ is encountered.
  Convert the char data input from the keyboard to an integer be
  Sure to account for the sign of the number.  If no sign is used
  always assume the number is positive.
*/
void main() {
	reset(1, 0, 0, 0); // Reset globals
	getdata();         // Get data
	while (c[0] != '@') { // Check for stop symbol '@'
		if (c[0] == '+' || c[0] == '-') { // Determine sign
			getdata(); // Get most significant byte
		} else {  // Default sign is '+'
			c[1] = c[0]; // Make room for the sign
			c[0] = '+';
			cnt++;
		}
		while(data) {  // Loop while there is data to process			
			if (c[cnt-1] == '\n') { // Process data now
				data = 0;
				tenth = 1;
				cnt = cnt - 2;

				while (!flag && cnt != 0) { // Compute a number
					opd(c[0], tenth, c[cnt]);
					cnt--;
					tenth *= 10;
				}
				if (!flag)  //  Good number entered
					printf("Operand is %d\n", opdv);
			} 
			else
				getdata(); // Get next byte of data
		}		
		reset(1, 0, 0, 0);  // Reset globals
		getdata();          // Get data
	}
}
示例#2
0
int AlignCD(char segm, int val)	//выравнять данные или код
{
	unsigned int a;
	a = (segm == DS ? outptrdata : outptr) % val;

	if (a == 0)
	{
		val = 0;
	}
	else
	{
		val -= a;
	}

	a = 0;

	while (val != 0)
	{
		segm == DS ? opd(aligner) : op(0x90);
		val--;
		a++;
	}

	return a;
}
void OpticalVortex::GetOpticalPathLengthDiff(double image_height,
                                             double angle,
                                             Mat_<double>* output) const {
  ZernikeWavefrontError(image_height, angle, output);
  Mat_<double>& opd = *output;

  const size_t kSize = opd.rows;
  const double kHalfSize = kSize / 2.0;
  const double kHalfSize2 = kHalfSize * kHalfSize;
  const double kPrimaryR2 = 1;
  const double kNumCycles = vortex_params_.num_cycles();
  const double k2Pi = 2 * M_PI;

  for (size_t i = 0; i < kSize; i++) {
    double y = i - kHalfSize;
    for (size_t j = 0; j < kSize; j++) {
      double x = j - kHalfSize;
      double r2 = (x*x + y*y) / kHalfSize2;

      if (r2 < kPrimaryR2) {
        double phase = atan2(y, x) / k2Pi;
        if (phase < 0) phase += 1;
        opd(i, j) += phase * kNumCycles;
      }
    }
  }
}
示例#4
0
void Axicon::GetOpticalPathLengthDiff(double image_height,
                                      double angle,
                                      Mat_<double>* output) const {
  ZernikeWavefrontError(image_height, angle, output);

  Mat_<double>& opd = *output;

  const size_t kSize = opd.rows;
  const double kHalfSize = kSize / 2.0;
  const double kHalfSize2 = kHalfSize * kHalfSize;
  const double kPrimaryR2 = 1;
  const double kNumCycles = axicon_params_.num_cycles();

  for (size_t i = 0; i < kSize; i++) {
    double y = i - kHalfSize;
    for (size_t j = 0; j < kSize; j++) {
      double x = j - kHalfSize;
      double r2 = (x*x + y*y) / kHalfSize2;

      opd(i, j) += (r2 < kPrimaryR2) ? sqrt(r2) * kNumCycles : 0;
    }
  }
}