<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p style="margin-top:0; margin-bottom:0">dear members, </p>
<p style="margin-top:0; margin-bottom:0">                             I came to know from stackoverflow that the following references a row in a matrix in C++:</p>
<p style="margin-top:0; margin-bottom:0">M[2] references 2nd row of the Matrix.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I am using Rcpp to write C++ code in R.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">However, I ended up with the following inconsistency:</p>
<p style="margin-top:0; margin-bottom:0"></p>
<div>> M</div>
<div>     x y z</div>
<div>[1,] 1 1 1</div>
<div>[2,] 2 2 2</div>
<div>[3,] 3 3 3</div>
<div>[4,] 4 4 4</div>
<div>[5,] 5 5 5</div>
<div>[6,] 6 6 6</div>
<div>> cppFunction('IntegerVector tccp3(IntegerMatrix M) { IntegerVector x = M[2]; return x;}')</div>
<div>> tccp3(M)</div>
<div>[1] 0 0 0</div>
<div>> cppFunction('IntegerVector tccp4(IntegerMatrix M) { IntegerVector x = M[1]; return x;}')</div>
<div>> tccp4(M)</div>
<div>[1] 0 0</div>
<div><br>
</div>
<div>tccp3 should return (3,3,3) and tccp4 should return  (2,2,2). Can you please shed light on what is going on?</div>
<div><br>
</div>
<div>very many thanks for your time and effort....</div>
<div><br>
</div>
<div>Yours sincerely,</div>
<div>AKSHAY M KULKARNI</div>
<p></p>
</div>
</body>
</html>