其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
C++ 的 MTL 库 示例(整理 by RobinKin from DevonIT)

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

//距阵copy 和 转置
// -*- c++ -*-
//
// $COPYRIGHT$
//
//===========================================================================

#include <iostream>
using namespace std;

#include <mtl/matrix.h>
#include <mtl/mtl.h>
#include <mtl/utils.h>
#include <mtl/linalg_vec.h>

/*
  Transpose matrix A into matrix B using mtl::copy.
  (We could use the mtl::transpose(A,B) function,
   but then this wouldn't be an example about mtl::copy)

  Sample Output

  3x3
  [
  [1,4,7],
  [2,5,8],
  [3,6,9]
  ]
  3x3
  [
  [1,2,3],
  [4,5,6],
  [7,8,9]
  ]
 
  */

using namespace mtl;

typedef matrix< double, rectangle<>,
                dense<>, column_major>::type Matrix; 

/* An external matrix - uses memory from some "outside" source, and
  just makes that memory look like an MTL Matrix */
typedef matrix< double, rectangle<>,
                dense<external>, column_major>::type EMatrix;

int
main()
{
  int i;
  const int N = 3;
  double da[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

  EMatrix A(da, N, N);
  Matrix B(N, N);

  print_all_matrix(A);

  // Copy the columns of A into the rows of B
  for (i = 0; i < N; ++i)
    copy(A[i], rows(B)[i]); // rows(B) creates a row-oriented view of B

  print_all_matrix(B);

  return 0;
}


 




相关文章

相关软件