@defer.inlineCallbacks
    def compute_state_delta(self, room_id, batch, sync_config, since_token, now_token,
                            full_state):
        # TODO(mjark) Check if the state events were received by the server
        # after the previous sync, since we need to include those state
        # updates even if they occured logically before the previous event.
        # TODO(mjark) Check for new redactions in the state events.

        with Measure(self.clock, "compute_state_delta"):
            if full_state:
                if batch:
                    current_state = yield self.store.get_state_for_event(
                        batch.events[-1].event_id
                    )

                    state = yield self.store.get_state_for_event(
                        batch.events[0].event_id
                    )
                else:
                    current_state = yield self.get_state_at(
                        room_id, stream_position=now_token
                    )

                    state = current_state

                timeline_state = {
                    (event.type, event.state_key): event
                    for event in batch.events if event.is_state()
                }

                state = _calculate_state(
                    timeline_contains=timeline_state,
                    timeline_start=state,
                    previous={},
                    current=current_state,
                )
            elif batch.limited:
                state_at_previous_sync = yield self.get_state_at(
                    room_id, stream_position=since_token
                )

                current_state = yield self.store.get_state_for_event(
                    batch.events[-1].event_id
                )

                state_at_timeline_start = yield self.store.get_state_for_event(
                    batch.events[0].event_id
                )

                timeline_state = {
                    (event.type, event.state_key): event
                    for event in batch.events if event.is_state()
                }

                state = _calculate_state(
                    timeline_contains=timeline_state,
                    timeline_start=state_at_timeline_start,
                    previous=state_at_previous_sync,
                    current=current_state,
                )
            else:
                state = {}

            defer.returnValue({
                (e.type, e.state_key): e
                for e in sync_config.filter_collection.filter_room_state(state.values())
            })
Solves Ax = B, where A is an upper triangular matrix.
dataset/ETHPy150Open matrix-org/synapse/synapse/handlers/sync.py/SyncHandler.compute_state_delta--crossover with--dataset/ETHPy150Open sympy/sympy/sympy/matrices/matrices.py/MatrixBase.upper_triangular_solve