Пример #1
0
    void
    factor_pair (const Ordinal n,
		 Scalar R_top[],
		 const Ordinal ldr_top,
		 Scalar R_bot[],
		 const Ordinal ldr_bot,
		 Scalar tau[],
		 Scalar work[])
    {
      const Ordinal numRows = Ordinal(2) * n;

      A_buf_.reshape (numRows, n);
      A_buf_.fill (Scalar(0));
      // Copy the inputs into the compute buffer.  Only touch the
      // upper triangles of R_top and R_bot, since they each may be
      // views of some cache block (where the strict lower triangle
      // contains things we don't want to include in the
      // factorization).
      copy_upper_triangle (n, n, &A_buf_(0, 0), A_buf_.lda(), R_top, ldr_top);
      copy_upper_triangle (n, n, &A_buf_(n, 0), A_buf_.lda(), R_bot, ldr_bot);

      int info = 0;
      lapack_.GEQR2 (numRows, n, A_buf_.get(), A_buf_.lda(), tau, work, &info);
      if (info != 0)
	{
	  std::ostringstream os;
	  os << "TSQR::CombineDefault::factor_pair(): "
	     << "GEQR2 failed with INFO = " << info;
	  throw std::logic_error (os.str());
	}

      // Copy back the results.  Only read the upper triangles of the
      // two n by n row blocks of A_buf_ (this means we don't have to
      // zero out the strict lower triangles), and only touch the
      // upper triangles of R_top and R_bot.
      copy_upper_triangle (n, n, R_top, ldr_top, &A_buf_(0, 0), A_buf_.lda());
      copy_upper_triangle (n, n, R_bot, ldr_bot, &A_buf_(n, 0), A_buf_.lda());
    }
Пример #2
0
    void
    apply_pair (const ApplyType& apply_type,
		const Ordinal ncols_C, 
		const Ordinal ncols_Q, 
		const Scalar R_bot[], 
		const Ordinal ldr_bot,
		const Scalar tau[], 
		Scalar C_top[], 
		const Ordinal ldc_top, 
		Scalar C_bot[], 
		const Ordinal ldc_bot, 
		Scalar work[]) 
    {
      const Ordinal numRows = Ordinal(2) * ncols_Q;

      A_buf_.reshape (numRows, ncols_Q);
      A_buf_.fill (Scalar(0));
      copy_upper_triangle (ncols_Q, ncols_Q, 
			   &A_buf_(ncols_Q, 0), A_buf_.lda(), 
			   R_bot, ldr_bot);
      C_buf_.reshape (numRows, ncols_C);
      copy_matrix (ncols_Q, ncols_C, &C_buf_(0, 0), C_buf_.lda(), C_top, ldc_top);
      copy_matrix (ncols_Q, ncols_C, &C_buf_(ncols_Q, 0), C_buf_.lda(), C_bot, ldc_bot);

      int info = 0;
      lapack_.ORM2R ("Left", apply_type.toString().c_str(), 
		     numRows, ncols_C, ncols_Q,
		     A_buf_.get(), A_buf_.lda(), tau,
		     C_buf_.get(), C_buf_.lda(),
		     work, &info);
      if (info != 0)
	throw std::logic_error ("TSQR::CombineDefault: ORM2R failed");

      // Copy back the results.
      copy_matrix (ncols_Q, ncols_C, C_top, ldc_top, &C_buf_(0, 0), C_buf_.lda());
      copy_matrix (ncols_Q, ncols_C, C_bot, ldc_bot, &C_buf_(ncols_Q, 0), C_buf_.lda());
    }
Пример #3
0
		const Ordinal nextCounter()		const { assert(counter() < 0xffff); return Ordinal(_ordinal+((uint64_t)1<<0)); }
Пример #4
0
		const Ordinal nextMinorIndex()		const { assert(minorIndex() < 0xffff); return Ordinal(_ordinal+((uint64_t)1<<16)); }
Пример #5
0
		const Ordinal nextMajorIndex()		const { assert(majorIndex() < 0xffff); return Ordinal(_ordinal+((uint64_t)1<<32)); }
Пример #6
0
 /// \brief Buffer length as a function of R factor dimension.
 ///
 /// \param ncols [in] Number of columns (and number of rows)
 ///   in the R factor input.
 Ordinal buffer_length (const Ordinal ncols) const {
   return (ncols * (ncols + Ordinal(1))) / Ordinal(2);
 }
Пример #7
0
char *validate_instruction(instruction *instr) {
	int argc = symbol_value(argcounts, instr->instruction);
	int cnt = count_args(instr);

	int idx;

	char *err_msg;

	argument *arg;

	if (Is_Meta) {
		argc = cnt;

		err_msg = Meta->validate(instr);
		if (err_msg)
			return err_msg;
	}

	if (cnt != argc) {
		sprintf(
			err_buf,
			"Wrong number of arguments for \"%s\".  Expected %i, parsed %i",
			instr->instruction,
			argc,
			cnt
		);
		return err_buf;
	}

	for (idx = 0, arg = instr->args; idx < cnt; idx++, arg = arg->next) {
		if ((Mode == mode_string) && ! String_Allowed) {
			sprintf(
				err_buf,
				"String arguments are not allowed for \"%s\"",
				instr->instruction
			);
			return err_buf;
		}

		if (Data_Required && ! mode_is_data(Mode)) {
			sprintf(
				err_buf,
				"\"%s\" accepts constant data arguments only",
				instr->instruction
			);
			return err_buf;
		}

		err_msg = validate_argument(arg);
		if (err_msg) {
			sprintf(
				err_buf,
				"%s arg: %s",
				Ordinal(idx),
				err_msg
			);
			return err_buf;
		}

	}

	return NULL;
}