used inplace doublematrix for better native performance