write back
     ‘ˆõ�þEÂ³rŠIeñ¶Ùüÿü„Bãÿû¿ø +¡   ‘
##  Copyright (C) 2010 - 2019  Dirk Eddelbuettel, Romain Francois and Kevin Ushey
##
##  This file is part of Rcpp.
##
##  Rcpp is free software: you can redistribute it and/or modify it
##  under the terms of the GNU General Public License as published by
##  the Free Software Foundation, either version 2 of the License, or
##  (at your option) any later version.
##
##  Rcpp is distributed in the hope that it will be useful, but
##  WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.

if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")

Rcpp::sourceCpp("cpp/Matrix.cpp")

#    test.List.column <- function() {
x <- matrix( 1:16+.5, nc = 4 )
res <- runit_Row_Column_sugar( x )
target <- list(x[1,], x[,1], x[2,], x[,2], x[2,] + x[,2])
expect_equal( res, target, info = "column and row as sugar" )


#    test.NumericMatrix <- function(){
x <- matrix( 1:16 + .5, ncol = 4 )
expect_equal( matrix_numeric(x), sum(diag(x)), info = "matrix indexing" )

y <- as.vector( x )
expect_error( matrix_numeric(y) , info = "not a matrix" )

#    test.CharacterMatrix <- function(){
x <- matrix( letters[1:16], ncol = 4 )
expect_equal( matrix_character(x), paste( diag(x), collapse = "" ) )

#    test.GenericMatrix <- function( ){
g <- function(y){
    sapply( y, function(x) seq(from=x, to = 16) )
}
x <- matrix( g(1:16), ncol = 4 )
expect_equal( matrix_generic(x), g(diag(matrix(1:16,ncol=4))), info = "GenericMatrix" )

#    test.IntegerMatrix.diag <- function(){
expected <- matrix( 0L, nrow = 5, ncol = 5 )
diag( expected ) <- 1L
expect_equal( matrix_integer_diag(), expected, info = "IntegerMatrix::diag" )

#    test.CharacterMatrix.diag <- function(){
expected <- matrix( "", nrow = 5, ncol = 5 )
diag( expected ) <- "foo"
expect_equal( matrix_character_diag(), expected, info = "CharacterMatrix::diag" )

#    test.NumericMatrix.Ctors <- function(){
x <- matrix(0, 3, 3)
expect_equal( matrix_numeric_ctor1(), x, info = "matrix from single int" )

x <- matrix(0, 3, 3)
expect_equal( matrix_numeric_ctor2(), x, info = "matrix from two int" )

#    test.IntegerVector.matrix.indexing <- function(){
x <- matrix( 1:16, ncol = 4 )
expect_equal( integer_matrix_indexing(x), sum(diag(x)), info = "matrix indexing" )

expect_equal( diag(integer_matrix_indexing_lhs(x)), 2*0:3, info = "matrix indexing lhs" )

y <- as.vector( x )
expect_error( integer_matrix_indexing_lhs(y) , info = "not a matrix" )

#    test.NumericMatrix.row <- function(){
x <- matrix( 1:16 + .5, ncol = 4 )
expect_equal( runit_NumericMatrix_row( x ), sum( x[1,] ), info = "iterating over a row" )

#    test.NumericMatrix.row.const <- function(){
x <- matrix( 1:16 + .5, ncol = 4 )
expect_equal( runit_NumericMatrix_row_const( x ), sum( x[1,] ), info = "iterating over a row" )


#    test.CharacterMatrix.row <- function(){
m <- matrix( letters, ncol = 2 )
expect_equal( runit_CharacterMatrix_row(m), paste( m[1,], collapse = "" ), info = "CharacterVector::Row" )

#    test.CharacterMatrix.row.const <- function(){
m <- matrix( letters, ncol = 2 )
expect_equal( runit_CharacterMatrix_row_const(m), paste( m[1,], collapse = "" ), info = "CharacterVector::Row" )

#    test.List.row <- function(){
m <- lapply( 1:16, function(i) seq(from=1, to = i ) )
dim( m ) <- c( 4, 4 )
expect_equal( runit_GenericMatrix_row( m ), 1 + 0:3*4, info = "List::Row" )

#    test.List.row.const <- function(){
m <- lapply( 1:16, function(i) seq(from=1, to = i ) )
dim( m ) <- c( 4, 4 )
expect_equal( runit_GenericMatrix_row_const( m ), 1 + 0:3*4, info = "List::Row" )

#    test.NumericMatrix.column <- function(){
x <- matrix( 1:16 + .5, ncol = 4 )
expect_equal( runit_NumericMatrix_column( x ), sum( x[,1] ) , info = "iterating over a column" )

#    test.NumericMatrix.column.cons