linear-complexity algorithms for linear algebra with matrices related to tree graphs