<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic triangularize a matrix in one go i.e. drotg &amp; dlasr in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/triangularize-a-matrix-in-one-go-i-e-drotg-dlasr/m-p/811004#M3916</link>
    <description>Oh, never mind, figured it out. Kind of hate that I need to copy over the c and s values at line 53.&lt;BR /&gt;&lt;BR /&gt;[cpp]/*
 * rotations_sandbox.cc
 *
 *  Created on: May 31, 2012
 *      Author: Giovanni Azua
 */
#include &lt;ASSERT.H&gt;
#include &lt;MATH.H&gt;
#include &lt;STDIO.H&gt;
#include &lt;STDLIB.H&gt;

#include &lt;MKL_LAPACK.H&gt;
#include &lt;MKL_LAPACKE.H&gt;
#include &lt;MKL_CBLAS.H&gt;

static const int ROWS = 3;
static const int COLS = 3;
static double matrix[ROWS][COLS];

static void print_matrix() {
	int rows = ROWS;
	int cols = COLS;
	printf("matrix of dimensions %dx%d: n", rows, cols);
	for (int i=0; i &amp;lt; rows; ++i) {
		for (int j=0; j &amp;lt; cols; ++j) {
			printf("%f ", matrix&lt;J&gt;&lt;I&gt;);
		}
		printf("n");
	}
}

int main(int argc, char** argv) {
	// create a simple matrix in "column major" with 1's in the
	// upper triangule and 2s in the band below the diagonal
	// now I want to get rid of the 2s using Givens rotations
	matrix[0][0] = 1; matrix[1][0] = 1; matrix[2][0] = 1;
	matrix[0][1] = 2; matrix[1][1] = 1; matrix[2][1] = 1;
	matrix[0][2] = 0; matrix[1][2] = 2; matrix[2][2] = 1;
	print_matrix();

	double cc[COLS];
	double ss[COLS];

	// create the rotations
	for (int j = 0; j &amp;lt; COLS; j++) {
		double a = matrix&lt;J&gt;&lt;J&gt;;
		double b = matrix&lt;J&gt;[j + 1];
		double c = 0.0;
		double s = 0.0;
		double r = 0.0;
		dlartg(&amp;amp;a, &amp;amp;b, &amp;amp;c, &amp;amp;s, &amp;amp;r);

		for (int jj = j; jj &amp;lt; COLS; ++jj) {
			cc[jj] = c;
			ss[jj] = s;
		}

		// apply the rotations along the diagonal
		char side      = 'L';
		char pivot     = 'V';
		char direct    = 'F';
		lapack_int m   = ROWS - j;
		lapack_int n   = COLS - j;
		lapack_int lda = ROWS;
		dlasr(&amp;amp;side, &amp;amp;pivot, &amp;amp;direct, &amp;amp;m, &amp;amp;n, &amp;amp;cc&lt;J&gt;, &amp;amp;ss&lt;J&gt;, ((double*) matrix) + j*ROWS + j, &amp;amp;lda);

		print_matrix();
	}

	return 0;
}
[/cpp]&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/I&gt;&lt;/J&gt;&lt;/MKL_CBLAS.H&gt;&lt;/MKL_LAPACKE.H&gt;&lt;/MKL_LAPACK.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/MATH.H&gt;&lt;/ASSERT.H&gt;</description>
    <pubDate>Fri, 01 Jun 2012 16:21:09 GMT</pubDate>
    <dc:creator>Azua_Garcia__Giovann</dc:creator>
    <dc:date>2012-06-01T16:21:09Z</dc:date>
    <item>
      <title>triangularize a matrix in one go i.e. drotg &amp; dlasr</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/triangularize-a-matrix-in-one-go-i-e-drotg-dlasr/m-p/811003#M3915</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I have been trying to use Givens rotations via a combination of &lt;B&gt;drotg&lt;/B&gt; and &lt;B&gt;dlasr&lt;/B&gt; but have not been able to get it right. Can anyone please help me out. Please find below the self contained code of what I am trying to acomplish.&lt;BR /&gt;&lt;BR /&gt;Many thanks in advance,&lt;BR /&gt;Best regards,&lt;BR /&gt;Giovanni&lt;BR /&gt;&lt;BR /&gt;[cpp]/*
 * test.cc
 *
 *  Created on: May 31, 2012
 *      Author: Giovanni Azua
 */
#include &lt;ASSERT.H&gt;
#include &lt;MATH.H&gt;
#include &lt;STDIO.H&gt;
#include &lt;STDLIB.H&gt;

#include &lt;MKL_LAPACK.H&gt;
#include &lt;MKL_LAPACKE.H&gt;
#include &lt;MKL_CBLAS.H&gt;

static const int ROWS = 3;
static const int COLS = 3;
static double matrix[ROWS][COLS];

static void print_matrix() {
    int rows = ROWS;
    int cols = COLS;
    printf("matrix of dimensions %dx%d: \n", rows, cols);
    for (int i=0; i &amp;lt; rows; ++i) {
        for (int j=0; j &amp;lt; cols; ++j) {
            printf("%f ", matrix&lt;J&gt;&lt;I&gt;);
        }
        printf("\n");
    }
}

int main(int argc, char** argv) {
    // create a simple matrix in "column major" with 1's in the
    // upper triangule and 2s in the band below the diagonal
    // now I want to get rid of the 2s using Givens rotations
    matrix[0][0] = 1; matrix[1][0] = 1; matrix[2][0] = 1;
    matrix[0][1] = 2; matrix[1][1] = 1; matrix[2][1] = 1;
    matrix[0][2] = 0; matrix[1][2] = 2; matrix[2][2] = 1;
    print_matrix();

    double c[COLS];
    double s[COLS];

    // create the rotations
    for (int j = 0; j &amp;lt; (COLS - 1); j++) {
        double a = matrix&lt;J&gt;&lt;J&gt;;
        double b = matrix[j + 1]&lt;J&gt;;
        cblas_drotg(&amp;amp;a, &amp;amp;b, &amp;amp;c&lt;J&gt;, &amp;amp;s&lt;J&gt;);
    }

    // apply the rotations along the diagonal
    char side      = 'L';
    char pivot     = 'V';
    char direct    = 'F';
    lapack_int m   = ROWS;
    lapack_int n   = COLS;
    lapack_int lda = ROWS;
    dlasr(&amp;amp;side, &amp;amp;pivot, &amp;amp;direct, &amp;amp;m, &amp;amp;n, c, s, (double*) matrix, &amp;amp;lda);
    print_matrix();

    return 0;
}[/cpp]&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/I&gt;&lt;/J&gt;&lt;/MKL_CBLAS.H&gt;&lt;/MKL_LAPACKE.H&gt;&lt;/MKL_LAPACK.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/MATH.H&gt;&lt;/ASSERT.H&gt;</description>
      <pubDate>Thu, 31 May 2012 20:40:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/triangularize-a-matrix-in-one-go-i-e-drotg-dlasr/m-p/811003#M3915</guid>
      <dc:creator>Azua_Garcia__Giovann</dc:creator>
      <dc:date>2012-05-31T20:40:29Z</dc:date>
    </item>
    <item>
      <title>triangularize a matrix in one go i.e. drotg &amp; dlasr</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/triangularize-a-matrix-in-one-go-i-e-drotg-dlasr/m-p/811004#M3916</link>
      <description>Oh, never mind, figured it out. Kind of hate that I need to copy over the c and s values at line 53.&lt;BR /&gt;&lt;BR /&gt;[cpp]/*
 * rotations_sandbox.cc
 *
 *  Created on: May 31, 2012
 *      Author: Giovanni Azua
 */
#include &lt;ASSERT.H&gt;
#include &lt;MATH.H&gt;
#include &lt;STDIO.H&gt;
#include &lt;STDLIB.H&gt;

#include &lt;MKL_LAPACK.H&gt;
#include &lt;MKL_LAPACKE.H&gt;
#include &lt;MKL_CBLAS.H&gt;

static const int ROWS = 3;
static const int COLS = 3;
static double matrix[ROWS][COLS];

static void print_matrix() {
	int rows = ROWS;
	int cols = COLS;
	printf("matrix of dimensions %dx%d: n", rows, cols);
	for (int i=0; i &amp;lt; rows; ++i) {
		for (int j=0; j &amp;lt; cols; ++j) {
			printf("%f ", matrix&lt;J&gt;&lt;I&gt;);
		}
		printf("n");
	}
}

int main(int argc, char** argv) {
	// create a simple matrix in "column major" with 1's in the
	// upper triangule and 2s in the band below the diagonal
	// now I want to get rid of the 2s using Givens rotations
	matrix[0][0] = 1; matrix[1][0] = 1; matrix[2][0] = 1;
	matrix[0][1] = 2; matrix[1][1] = 1; matrix[2][1] = 1;
	matrix[0][2] = 0; matrix[1][2] = 2; matrix[2][2] = 1;
	print_matrix();

	double cc[COLS];
	double ss[COLS];

	// create the rotations
	for (int j = 0; j &amp;lt; COLS; j++) {
		double a = matrix&lt;J&gt;&lt;J&gt;;
		double b = matrix&lt;J&gt;[j + 1];
		double c = 0.0;
		double s = 0.0;
		double r = 0.0;
		dlartg(&amp;amp;a, &amp;amp;b, &amp;amp;c, &amp;amp;s, &amp;amp;r);

		for (int jj = j; jj &amp;lt; COLS; ++jj) {
			cc[jj] = c;
			ss[jj] = s;
		}

		// apply the rotations along the diagonal
		char side      = 'L';
		char pivot     = 'V';
		char direct    = 'F';
		lapack_int m   = ROWS - j;
		lapack_int n   = COLS - j;
		lapack_int lda = ROWS;
		dlasr(&amp;amp;side, &amp;amp;pivot, &amp;amp;direct, &amp;amp;m, &amp;amp;n, &amp;amp;cc&lt;J&gt;, &amp;amp;ss&lt;J&gt;, ((double*) matrix) + j*ROWS + j, &amp;amp;lda);

		print_matrix();
	}

	return 0;
}
[/cpp]&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/I&gt;&lt;/J&gt;&lt;/MKL_CBLAS.H&gt;&lt;/MKL_LAPACKE.H&gt;&lt;/MKL_LAPACK.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/MATH.H&gt;&lt;/ASSERT.H&gt;</description>
      <pubDate>Fri, 01 Jun 2012 16:21:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/triangularize-a-matrix-in-one-go-i-e-drotg-dlasr/m-p/811004#M3916</guid>
      <dc:creator>Azua_Garcia__Giovann</dc:creator>
      <dc:date>2012-06-01T16:21:09Z</dc:date>
    </item>
  </channel>
</rss>

